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


Please Help Members By Posting Answers For Below Questions

What's the difference between constant char *p and char * constant p?

667


explain what is fifo?

645


Design a program which assigns values to the array temperature. The program should then display the array with appropriate column and row headings.

1777


What is use of null pointer in c?

578


Is main is a keyword in c?

618






What is structure in c definition?

581


What is #define in c?

636


What is a const pointer in c?

679


Can the size of an array be declared at runtime?

623


How can I do graphics in c?

603


Can we assign integer value to char in c?

624


Under what circumstances does a name clash occur?

704


How can I convert a number to a string?

616


What is the use of void pointer and null pointer in c language?

639


What is difference between function overloading and operator overloading?

666