printf(“Enter two numbers:”);
printf(“nEnter your choice:”);
case 1: res=a+b;
case 2: res=a-b;
case 3: res=a*b;
case 4: res=a/b;
default: printf(“Wrong choice!!nPress any key…”);
19 thoughts on “C program to perform arithmetic operations using switch case”
how getch(); is coming 2 times is it possible…?
to do division like this
we have to tell that b!=0
case 4:if (b!=0)
printf("Division not possible");
how remove the decimal in result ?
For that just use integer type instead of float.
Thanks. Why do we add a getch function at the end of the function. We can also freeze output on screen using scanf function. I observed this coding pattern everywhere.
Because in case of getch() the output screen is stopped until we press any key. But in case of scanf() we have to give some input and then press enter to disappear the screen. So getch() is better way to stop output screen.
What mean by Exit(0)
It will terminate program execution.
i ask one question i did’t understand the answer
its saying statement missing
How a program To perform arthemetic operation using arthemetic
I want output for this program
write a program in c++ to input two numbers & perform all arithmetic operations with if else
why are we using the ch and res for
I don’t understand ,when to use %f and when to use %d. please clear my doubts
When you want to print or read float value or value with decimal then use %f. For integer value use %d.
programm is not running
there is error in the program bruh!
result is not running