Stimulate calculators to perform addition,subtraction,multiplication and division on two numbers using if/else statement?



Stimulate calculators to perform addition,subtraction,multiplication and division on two numbers usi..

Answer / 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

More C Interview Questions

What are the valid places to have keyword “break”?

0 Answers  


Between macros and functions,which is better to use and why?

0 Answers  


Is printf a keyword?

0 Answers  


What are volatile variables?

1 Answers   Mind Tree,


What is the process to generate random numbers in c programming language?

0 Answers  






what is the use of getch() function in C program.. difference b/w getch() and getche()??

29 Answers   HCL, IBM, Infosys, TCS, Wipro,


write a C and C++ programme to implement the A,bubble sort B,quick sort C,insertion sort D,sequential search E,binary search

1 Answers   ADP, TCS,


What is static volatile in c?

0 Answers  


How does C++ help with the tradeoff of safety vs. usability?

1 Answers  


write a program to swap Two numbers without using temp variable.

75 Answers   EMC, Focus, GreyB, HCL, Hitech, HP, Huawei, Infosys, Mannar Company, Microsoft, Miles Software, Odessa Technologies, Satyam, TCS, Wipro,


A character flag or control mechanism that delineates one data item from another a) variable b) constant c) delimiter d) call by reference

0 Answers  


What is the difference between procedural and functional programming?

0 Answers  


Categories