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 is the Purpose of 'extern' keyword in a function declaration?
Why is not a pointer null after calling free?
#include main() { char s[] = "Bouquets and Brickbats"; printf(" %c, ",*(&s[2])); printf("%s, ",s+5); printf(" %s",s); printf(" %c",*(s+2)); }
What is the -> in c?
Why is it usually a bad idea to use gets()? Suggest a workaround.
What are the advantages of the functions?
Which header file should you include if you are to develop a function which can accept variable number of arguments?
Differentiate between new and malloc(), delete and free() ?
Which is best linux os?
What is wrong in this statement?
What is #include stdio h and #include conio h?
What tq means in chat?
Why is structure important for a child?
How can I pad a string to a known length?
What is the symbol indicated the c-preprocessor?