Stimulate calculators to perform addition,subtraction,multiplication and division on two numbers using if/else statement?
Answer Posted / guest
void main()
{
int n,a,b;
sanf("%d%d",&a,&b);
printf("select one of these");
printf("1.addition
2.subtraction
3.multiplication
4.division");
scanf("%d",&n);
if(n==1)
{
printf("%d",a+b);
}
else if(n==2)
{
printf("%d",a-b);
}
else if(n==3)
{
printf("%d",a*b);
}
else if(n==4)
{
printf("%d",a/b);
}
else
{
printf("nothing to print");
}
}
Is This Answer Correct ? | 13 Yes | 4 No |
Post New Answer View All Answers
What's the difference between constant char *p and char * constant p?
explain what is fifo?
Design a program which assigns values to the array temperature. The program should then display the array with appropriate column and row headings.
What is use of null pointer in c?
Is main is a keyword in c?
What is structure in c definition?
What is #define in c?
What is a const pointer in c?
Can the size of an array be declared at runtime?
How can I do graphics in c?
Can we assign integer value to char in c?
Under what circumstances does a name clash occur?
How can I convert a number to a string?
What is the use of void pointer and null pointer in c language?
What is difference between function overloading and operator overloading?