Tuesday, January 31, 2012

CALCULATOR


#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<math.h>
#include<process.h>
#include<stdlib.h>
void main()
{
clrscr();
int i;
printf("****  WELCOME TO THE CALCULATION WORLD  ****");
printf(" \n****NOW CHOOSE ONE OF THE FOLLOWING OPTIONS ****");
printf("\n  {1}  ADDDITION  ");
printf("\n  {2}  SUBTRACTION  ");
printf("\n  {3}  MULTIPLICATION ");
printf("\n  {4}  DIVIDE ");
printf("\n  {5}  POWER ");
printf("\n  {6}  SQUAREROOT");
printf("\n  {7}  INVERSE");
printf("\n  {8}  FACTORIAL");
printf(“\n  {9}  EXIT  “);
printf("\n   PLEASE ENTER THE VALUE \n");
printf("   ");
scanf(" %d",&i);

switch(i)
{
case 1:

int a,b,z,sum=0;
printf("\n ENTER FIRST NUMBER ");
scanf("%d",&a);
printf("\n ENTER SECOND NUMBER ");
scanf("%d",&b);
z=a+b;
sum=z;
printf("\nSUM IS %d",sum);
break;

case 2:
int c,d,subtraction=0;
printf("\n ENTER FIRST NUMBER ");
scanf("%d",&c);
printf("\n ENTER SECOND NUMBER ");
scanf("%d",&d);
if(c>d)
{
subtraction=c-d;
printf("SUBTRACTION IS =%d",subtraction);
}
else
{
subtraction=d-c;
printf("SUBTRACTION IS -%d",subtraction);
}
break;

case 3:
int e,f,multiplication=0;
printf("ENTER THE FIRST NUMBER  ");
scanf("%d",&e);
printf("\nENTER SECOND NUMBER ");
scanf("%d",&f);
multiplication=e*f;
printf("MULTIPLICATION IS =%d",multiplication);
break;

case 4:
int g,h,remainder=0,quotient=0;
printf("ENTER THE FIRST NUMBER  ");
scanf("%d",&g);
printf("\nENTER SECOND NUMBER ");
scanf("%d",&h);
remainder=g%h;
quotient=g/h;
printf("REMAINDER=%d",remainder);
printf("\nQUOTIENT=%d",quotient);
break;

case 5:
int j,k,power=0;
printf("FIRST NUMBER IS BASE AND SECOND IS POWER\n");
printf("ENTER FIRST NUMBER  ");
scanf("%d",&j);
printf("\nENTER SECOND NUMBER ");
scanf("%d",&k);
power=pow(j,k);
printf("POWER VALUE IS=%d",power);
break;

case 6:
float l,squareroot=0;
printf("ENTER THE VALUE OF WHICH WE HAVE TO FIND SQUARE ROOT  ");
scanf("%d",&l);
squareroot=sqrt(l);
printf("THE SQUARE ROOT =%d",squareroot);
break;

case 7:
float m;
float n;
printf("ENTER THE VALUE FOR WHICH WE HAVE TO FIND INVERSE  ");
scanf("%f",&m);
n=1/m;
printf("INVERSE IS =%f",n);
break;

case 8:
int fact=1,o,p,q;

printf("ENTER THE VALUE FOR WHICH WE HAVE TO FIND FACTORIAL  ");
scanf("%d",&o);
for(p=1;p<=o;p++)
{
fact=fact*p;
}
printf("FACTORIAL =%d",fact);
break;

case 9:
exit(0);
default:
printf("PLEASE ENTER THE VALID OPTION !");
sound(1000);

}

getch();
}


1 comment:

  1. Looking for a hassle-free pathway to secure a seat at Vydehi Medical College? College Dhundo offers valuable insights on "Direct Admission In Vydehi Medical College Direct Admission In Vydehi Medical College Explore this informative resource to simplify your admission process and achieve your medical education goals.

    ReplyDelete