Tuesday, 3 April 2018

Arithmetic Operators in C


//Arithmetic Operators
//+ - * /
#include<stdio.h>
#include<conio.h>
void main()
{
 float x,y,sum,diff,pro,div;
 clrscr();
 printf("Enter first value\n");
 scanf("%f",&x);
 printf("Enter second value\n");
 scanf("%f",&y);
 sum=x+y;
 printf("\nAfter adding %.2f to %.2f the answer is = %.2f",x,y,sum);
 diff=x-y;
 printf("\nAfter subtracting %.2f from %.2f the answer is = %.2f",y,x,diff);
          pro=x*y;
 printf("\nAfter multiplying %.2f with %.2f the answer is = %.2f",x,y,pro);
 if(y==0)
          {
  printf("Division is not possible");
 }
 else
          {
  div=x/y;
  printf("\nAfter dividing %.2f by %.2f the answer is = %.2f",x,y,div);
 }
          getch();
}


No comments:

Post a Comment

Note: only a member of this blog may post a comment.