Make a new start with a new Thought!

NOTE :                // indicates comments.This wont get printed in the output.This is used for for documentation purpose. PROGRAM : ...

Calculator

NOTE :
              
// indicates comments.This wont get printed in the output.This is used for for documentation purpose.

PROGRAM :

#include<stdlib.h>
#include<conio.h>
void main()
{
 int a,b,opt;  // opt is for option
 clrscr();
 printf("\t\t\t*****CALCULATOR\n");   
 printf("Enter a,b values\t:\t");    
 scanf("%d%d",&a,&b);   
 printf("\nOPTIONS\t:\n");  
 printf(" 1)ADDITION \n 2)SUBSTRACTION \n 3)MULTIPLICATION \n 4)DIVISION\n");  
 printf("\nEnter your option\t:\t"); 
 scanf("%d",&opt);     
 switch(opt)           
 {
  case 1:
printf("\n %d + %d = %d",a,b,a+b);    
break;
  case 2:
printf("\n %d - %d = %d",a,b,a-b);     
break;
  case 3:
printf("\n %d * %d = %d",a,b,a*b);     
break;
  case 4:
printf("\n %d / %d = %d",a,b,a/b);     
break;
  default:                                 
printf("\nEnter a valid option\n");
 }
 printf("\n T H A N K  Y O U!\n");
 getch();
}

OUTPUT :


0 comments: