Sunday, 7 August 2016

Arithmetic operators in C ( + , - , * , / , % )



/* all the arithmetic operators in C ( + , - , * , / , % ) */

#include <stdio.h>
void main()
{
 int a = 21;
 int b = 10;
 int c ;
 c = a + b;
 printf("Line 1 - Value of c is %d\n", c );
 c = a - b;
 printf("Line 2 - Value of c is %d\n", c );
 c = a * b;
 printf("Line 3 - Value of c is %d\n", c );
 c = a / b;
 printf("Line 4 - Value of c is %d\n", c );
 c = a % b;
 printf("Line 5 - Value of c is %d\n", c );

}
output :
Line 1 - Value of c is 31
Line 2 - Value of c is 11
Line 3 - Value of c is 210
Line 4 - Value of c is 2
Line 5 - Value of c is 1

No comments:

Post a Comment

smhjifrivly@gmail.com