Simple calculator program in c using switch
How to create simple calculator program in c using switch Easily.It is very helpful programming coding for a beginners programmer.Switch statement is very important in c language.
This program created one kinds of software needed for this software is code blocks .
You can download now click here
#include<stdio.h>
int main()
{
char option;
int n,num1,num2,result;
do{
printf("*****Caculator*****\n");
printf("\n what operation do you want to do ...??\n");
printf("press 1 for addition \n");
printf("press 2 for subtraction \n");
printf("press 3 for multiplication \n");
printf("press 4 for division \n");
scanf("%d",&n);
printf("Enter 1st number :");
scanf("%d",&num1);
printf("Enter 2nd number :");
scanf("%d",&num2);
switch(n){
case 1:result=num1+num2;
printf("\n summation of:%d\n",result);
break;
case 2:result=num1-num2;
printf("\n subtraction of:%d\n",result);
break;
case 3:result=num1*num2;
printf("\n multiplication of:%d\n",result);
break;
case 4:result=num1/num2;
printf("\n division of:%d\n",result);
break;
default : printf("wrong...");
}
printf("\a\n Do you want to continue y/n");
option=getche();
}
while(option=='y');
return 0;
}
This programs output is:
How to create simple calculator program in c using switch Easily
Reviewed by Pronce
on
January 05, 2017
Rating:
No comments: