Example on Operators in C

 Example on  Operators in C

AIM : To study all mathematical operators.

program :For performing all the mathematical operations on a given set of number.

#include <stdio.h>

#include <conio.h>

Void main()

{

Int a, b, c, d;

clrscr();

printf(“The program for different math operations . \n”);

printf(“enter the two number”);

scanf(“%d %d”, &a, &b);

c=a+b;

printf(“addition of %d and %d is %d \n”,a,b ,c);

c=a-b;

printf(“subtraction of %d and %d is %d \n” ,a ,b ,c);

c=a*b;

printf(“multiplication of %d and %d is %d \n” ,a ,b ,c);

c=a\b;

printf(“division of %d and %d is %d \n” ,a ,b ,c);

d=a%b;

printf(“Quotient obtained from division of %d  and %d is %d “,a,b,c);

printf(“and reminder is %d”,d);

getch();

Program Description:

First, we have declared four different variables a, b, c and d. Variables a and b are used to store input values and variable c is used to store the result of addition, subtraction, multiplication, and division, variable d is used to store the result of modulus.

When we execute the program we have provided the two numbers as input from the user and these values are stored in variables a and b.

After this by providing a statement for addition c=a+b, subtraction  c=a-b, multiplication c=a*b, division c=a\b, and modulus d=a%b, after each operation we have added one printf statement to display the result of each operation separately as an output/result on the output console window.


Post By: Ms. Shweta Chaudhari| B. Tech Student


Read More: Operator in C

Newest
Previous
Next Post »