Addition, Subtraction, Multiplication, Division with C language
#include<stdio.h>
int main()
{
int a, b;
/*a= 4;
b= 2;*/
printf("Enter the values you want to calculate\n");
scanf("%d %d", &a , &b);
printf("a+b = %d\n", a+b);
printf("a-b = %d\n", a-b);
printf("a*b = %d\n", a*b);
printf("a/b = %d\n", a/b);
return 0;
}
There is two options available for you, you simply put the values of the variables in the first line(that was just comment out there you can see the code & in the picture) or you just simply use the "scanf" to get input from user.
In the division output sometimes you will get '0' as result because here we used "int" not "float" .
I wish you get help from this, thank you.
Comments
Post a Comment