Tuesday, 4 November 2014

HOW TO MAKE A SIMPLE CALCULATER IN C

HOW TO MAKE A SIMPLE CALCULATER IN C



Simple calculator Posted By: programer boy shubham
Category: C Programming Views: 14666 


This is a program for beginners in c programming. This programs helps the beginners to learn about various arithmetic operators and the use of function....

#include<stdio.h>
#include<conio.h>
#include
void main()
{
 int add(),sub(),mult(),div();
 int o;
while(1)
 {
 clrscr();
 printf("\nEnter the operator\nHINT\n----\n1 for +\n2 for -\n3 for *\n4 for /\n5 for exit"); scanf("%d",&o); switch(o) { case 1: add(); // calling function break; case 2: sub();
 break;
 case 3: mult();
break;
 case 4: div();
break;
case 5: exit(0);
 }
 }
 }
 int add() //calling add function
{
 int a,b,c; printf("Enter the numbers");
 scanf("%d%d",&a,&b);
 c=a+b;
 printf("%d + %d = %d",a,b,c);
 getch();
 return(0); 
}
 int sub() { int a,b,c; printf("Enter the numbers");
 scanf("%d%d",&a,&b);
 c=a-b;
 printf("%d - %d= %d",a,b,c);
 getch();
 return(0);
 }
 int mult()
{
int a,b,c;
 printf("Enter the numbers");
scanf("%d%d",&a,&b);
 c=a*b;
 printf("%d X %d = %d",a,b,c);
 getch();
 return(0);
 }
int div()
 {
int a,b,c;
 printf("Enter the numbers");
 scanf("%d%d",&a,&b);
 c=a/b;
printf("%d / %d = %d",a,b,c);
 getch();
 return(0);
}


BLOGGER--PROGRAMER BOY SHUBHAM
EMAIL-SHUBHAMPANDEY556@gmial.com

No comments:

Post a Comment