Arithmetic Operations
In
this tutorial we are going to see how to perform arithmetic operations in a
single program. We can even try a single arithmetic operation addition,
subtraction, multiplication and division etc….
#include <stdio.h>
int main()
{
int a = 10,b = 5, c;
c = a+b;
printf("a+b = %d
\n",c);
c = a-b;
printf("a-b = %d
\n",c);
c = a*b;
printf("a*b = %d
\n",c);
c = a/b;
printf("a/b = %d
\n",c);
return 0;
}
Output:
a+b=15
a-b=5
a*b=50
We are using stdio.h to get the standard input and
output of the program.
v As a constant we are
declaring a=10, b=5 and as a
variable we are declaring c.
v Now we are declaring c=a+b and in the printf we are
declaring the string a+b=%d. we are
declaring %d to declare a integer c .so we are using , c next to the string.
v Like above we should do
the same things for the following operations. After that we are using return 0 to declare the main function’s Exit status.
Thus
we got the output. Try it out of your own to learn more!!!