C Program Calculator
/*
Write a program to make a simple calculator using switch..case statement.
*/
#include <stdio.h>
int main(void) {
int a=10,b=20,ch;
do
{
printf("\n================");
printf("\nSelect Operation");
printf("\n================");
printf("\n1 - Addition");
printf("\n2 - Substraction");
printf("\n3 - Multiplication");
printf("\n4 - Division");
printf("\n5 - Modulo");
printf("\n6 - Exit");
printf("\n================");
printf("\nEnter Your Choice :");
scanf("%d",&ch);
printf("Enter First Value :");
scanf("%d",&a);
printf("Enter Second Value :");
scanf("%d",&b);
switch(ch)
{
case 1:
printf("\nAnswer = %d",a+b);
break;
case 2:
printf("\nAnswer = %d",a-b);
break;
case 3:
printf("\nAnswer = %d",a*b);
break;
case 4:
printf("\nAnswer = %d",a/b);
break;
case 5:
printf("\nAnswer = %d",a%b);
break;
case 6:
printf("\nThanks for Using Program");
break;
}
}while(ch!=6);
return 0;
}
Write a program to make a simple calculator using switch..case statement.
*/
#include <stdio.h>
int main(void) {
int a=10,b=20,ch;
do
{
printf("\n================");
printf("\nSelect Operation");
printf("\n================");
printf("\n1 - Addition");
printf("\n2 - Substraction");
printf("\n3 - Multiplication");
printf("\n4 - Division");
printf("\n5 - Modulo");
printf("\n6 - Exit");
printf("\n================");
printf("\nEnter Your Choice :");
scanf("%d",&ch);
printf("Enter First Value :");
scanf("%d",&a);
printf("Enter Second Value :");
scanf("%d",&b);
switch(ch)
{
case 1:
printf("\nAnswer = %d",a+b);
break;
case 2:
printf("\nAnswer = %d",a-b);
break;
case 3:
printf("\nAnswer = %d",a*b);
break;
case 4:
printf("\nAnswer = %d",a/b);
break;
case 5:
printf("\nAnswer = %d",a%b);
break;
case 6:
printf("\nThanks for Using Program");
break;
}
}while(ch!=6);
return 0;
}
Comments
Post a Comment