A program to read 2 values and explain arithmetic operators (+, -,*,/)
C Programming Language 004
The following code shows how to write a program to read 2 values and explain arithmetic operators (+, -,*,/)
Program
#include <stdio.h>
void main()
{
int a, b, c, d, e, f;
printf("Enter values of a,b: ");
scanf("%d %d", &a, &b);
c = a + b;
d = a - b;
e = a * b;
f = a / b;
printf("a + b = %d\n", c);
printf("a - b = %d\n", d);
printf("a * b = %d\n", e);
printf("a / b = %d\n", f);
printf("\n");
}
Result
Enter values of a,b: 7 2
a + b = 9
a - b = 5
a * b = 14
a / b = 3
Last Updated on
Comments