Shopping In MUMBAI

Are you searching for Discounts, offers, sale in Mumbai ? You are in the right place. MUMBAI, a shopping haven, has no dearth of great discounts and sales. This blog features the best MUMBAI shopping offers, sale, discounts and deals and bargains CURRENTLY GOING on in Mumbai plus a few free things thrown in on top. Don't wait for it because once they are gone, they are gone. Hurry!..By clicking the "Like" button you will receive a daily update of discounts, sale, offers going on in Mumbai. LIKE IT.... SHARE IT...njoY.

Wednesday, December 31, 2008

C Program to function for a calculator

C Program to function for a calculator

#include
#include
void main()
{
int ch ,a,b;
float res;
clrscr();
printf("\n1:Addition");
printf("\n2:Subtraction");
printf("\n3:Multiplication");
printf("\n4:Division");
while(1)
{
printf("\nEnter two numbers:");
scanf("%d %d",&a,&b);
printf("\nEnter the choice:");
scanf("%d",&ch);
switch(ch)
{
case 1:
res=a+b;
printf("\nAddition is %0.0f: ",res);
break;

case 2:
res=a-b;
printf("\nSubtraction is %0.0f: ",res);
break;

case 3:
res=a*b;
printf("\nMultiplication is %0.0f: ",res);
break;

case 4:
res=a/b;
printf("\nDivision is %0.0f: ",res);
break;

default:
printf("exit");
exit();
}
}
getch();
}
*************OUTPUT**************
1:Addition
2:Subtraction
3:Multiplication
4:Division
Enter two numbers:2 3

Enter the choice:1

Addition is 5:
Enter two numbers:5 4

Enter the choice:3

Multiplication is 20:
Enter two numbers:3 8

Enter the choice:5
exit

C Program to function for a calculatorSocialTwist Tell-a-Friend

0 comments:

SUPPORT THIS BLOG