Wisdom Materials
Home
About Us
Our Clients
Careers
Services
Education
Jobs
News
Business
Health
Astrology
Entertainment
RealEstate
Devotion
Contact Us
C Programs
/ switch statement C program
Program Name
Write a C Program for switch statement.
Theory
Program Code
Copy Program Code
#include
int main() { int num1,num2,result,op; printf("Enter two numbers"); scanf("%d%d",&num1,&num2); printf("Enter option Addition==1 \n Substraction==2 \n Multiplication==3 \n Division==4\n"); scanf("%d",&op); switch(op) { case 1: result= num1+num2; printf("Sum= %d",result); break; case 2: result= num1-num2; printf("Difference= %d",result); break; case 3: result= num1*num2; printf("Product= %d",result); break; case 4: result= num1/num2; printf("Quotient = %d",result); if(num1>=num2) printf("First is big"); else printf("second is big"); break; default:printf("It is not valid option"); break; } return 0; }
Input
Enter two numbers4 2 Enter option Addition==1 Substraction==2 Multiplication==3 Division==4 1
Output
Sum= 6
Online C Compiler (To copy paste and Run the c program)
Home
Back