Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

Calculator in C

#include<stdio.h>
#include<conio.h>

void main()
{
char choice;
int a,b,res=0;
clrscr();
printf("Enter First value: ");
scanf("%d",&a);
printf("
 Enter Operator: ");
choice=getch();
printf("
 Enter Second value: ");
scanf("%d",&b);

switch(choice)
{
case '+':
  res=a+b;
  printf("Sum: %d",res);
break;
case '-':
  res=a-b;
  printf("Difference: %d",res);
break;
case '*':
  res=a*b;
  printf("Product: %d",res);
break;
case '/':
  res=a/b;
  printf("Quotient: %d",res);
break;
default:
  printf("Enter Valid Operator!!");
}
getch();
}
Source by www.sitesbay.com #
 
PREVIOUS NEXT
Tagged: #Calculator #C
ADD COMMENT
Topic
Name
4+1 =