You are here:   HomeC Programming (Theory)Control Structures in CWrite a C program to display the series of numbers as given below
by Dinesh Thakur Category: Control Structures

 

 

#include<stdio.h>

#include<conio.h>
main()
{
int select,x,y,z;
clrscr();
printf("\n Specify the two numbers:");
scanf("%d%d",&x,&y);
printf("\n Select 1 to Perform Addition");
printf("\n Select 2 to Perform Subtraction");
printf("\n Select 3 to Perform Multiplication");
printf("\n Select your choice");
scanf("%d",&select);
if(select!=1||select!=2||select!=3)
exit(1);
else
switch(select);
case 1: z=x+y;
printf("Result after Addition:%d",z);
break;
case 2: z=x-y;
printf("Result after Subtraction:%d",z);
break;
case 3: z=x*y;
printf("\n Result after Multiplication:%d",z);
break;
}
}
getch();
}
 
OUTPUT:
 
Specify the two numbers: 12 5
Select your choice 2
Result after Subtraction: 7


Subscribe To Free Daily Newsletter!

Get Free News Updates Delivered Directly To Your Inbox
About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular Computer Notes blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to contact us.



What's New and Popular





Popular Article