Sunday, 11 May 2014

calculater Programe in C


·         #include <stdio.h>
·         #include <conio.h>
·         int main ()
·         {
·          
·          char c;
·          int a, b, res,d;
·         printf("Select one of era-thematic operation "
"to perfume the following operations: \n+\n-\n*\n/\"
"nEnter you's choice: ");
scanf("%c",&c);

switch(c)
{
case '+' :
 printf("Enter 1st Number:");
 scanf("%d",&a);
 printf("\nEnter 2nd Number:");
 scanf("%d",&b);
 res=a+b;
 printf("%d + %d= %d",a,b,res);

break;

 case '-':
 printf("Enter 1st Number:");
    scanf("%d",&a);
 printf("\nEnter 2nd Number:");
 scanf("%d",&b);
 res=a-b;
 printf("%d - %d= %d",a,b,res);
break;

case '*':
 printf("Enter 1st Number:");
 scanf("%d",&a);
 printf("\nEnter 2nd Number:");
 scanf("%d",&b);
 res=a*b;
 printf("%d * %d= %d",a,b,res);
break;

case '/':
 printf("Enter 1st Number:");
 scanf("%d",&a);
 printf("\nEnter 2nd Number:");
 scanf("%d",&b);
 res=a/b;
 printf("%d / %d= %d",a,b,res);
break;

default:
  printf("Invalid Entry");
}


getch();
return 0;



}

No comments:

Post a Comment