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 is a lvalue

665


What is the function of this pointer?

674


a c variable cannot start with a) an alphabet b) a number c) a special symbol d) both b and c above

686


how can I convert a string to a number?

597


What is the full form of getch?

585






What is #include called?

570


What is the right type to use for boolean values in c?

587


explain what is fifo?

634


What is string concatenation in c?

568


What are volatile variables in c?

522


What are the data types present in c?

629


a program that performs some preliminary processing in C, it acts upon certain directives that will affect how the compiler does its work a) compiler b) loader c) directive d) preprocessor

641


What would be an example of a structure analogous to structure c?

577


Explain bit masking in c?

639


In C programming, how do you insert quote characters (‘ and “) into the output screen?

895