C Program To Create Arthematic Operations In Switch Case

#include<stdio.h>
#include<conio.h>
void main()
{
 int opt,opt1,opt2,opt3,opt4,add,sub,mul,num1,num2;
 float div;
 clrscr();
 printf("enter num1,num2");
 scanf("%d%d",&num1,&num2);
 printf("\n 1.addition \n 2.subtraction \n 3.multiplication \n 4.division \n");
 scanf("%d",&opt);
 switch(opt);
 {
 switch(opt==1)
 {
  add=num1+num2;
  printf("addition is %d",add);
  break;
 }
 switch(opt==2)
 {
  sub=num1-num2;
  printf("subtraction is %d",sub);
  break;
 }
 switch(opt==3)
 {
  mul=num1*num2;
  printf("multiplication is %d",mul);
  break;
 }
 switch(opt==4)
 {
  div=num1/num2;
  printf("division is %f",div);
  break;
 }
 }
 getch();
}
Bhanu Namikaze

Bhanu Namikaze is an Ethical Hacker, Web Developer, Student and Mechanical Engineer. He Enjoys writing articles, Blogging, Solving Errors and Social Networking. Feel Free to let me know any of your concerns about hacking or let me know if you need any more methods on hacking anything. Enjoy Learning

No comments:

Post a Comment