C Program to Demonstrate Arithmetic Operators
Write C Code to Demonstrate Arithmetic Operators
//Write a c program to demonstrate various arithmetic operation #include <stdio.h> int main() { int a = 12; int b = 8; int c ; printf("The value of num1 is : %d ",a); printf("\nThe value of num2 is : %d ",b); c = a + b; printf("\n\n%d + %d \t= %d\n", a, b, c ); c = a - b; printf("%d - %d \t= %d\n", a, b, c ); c = a * b; printf("%d * %d \t= %d\n", a, b, c ); float d = a / (float)b; printf("%d / %d \t= %f\n", a, b, d ); c = a % b; printf("%d mod %d = %d\n", a, b, c ); c = a + 1; printf("%d + 1 \t= %d\n", a, c ); c = a - 1; printf("%d - 1 \t= %d\n", a, c ); return 0; }
Output:
The value of num1 is : 12
The value of num2 is : 8
12 + 8 = 20
12 - 8 = 4
12 * 8 = 96
12 / 8 = 1
12 mode 8 = 4
12 + 1 = 13
12 - 1 = 11