LED PANEL

Google It, You'll Get It.

Monday, January 31, 2011

Calculator using if and while to run till you need

#include<'stdio.h'>
#include<'conio.h'>

main()
{
int a, b, sum;
char choice = 'y';
char select;
while(choice == 'y')
{
printf("Enter the two values : \n");
scanf("%d %d",&a,&b );
flushall();

printf("/n/n MENU ");
printf(" a. Addition ");
printf(" b. Subtraction ");
printf(" c. Multiplication ");
printf(" d. Division ");
printf(" e. Exit /n/n");

printf("/n Select from above : ");
scanf("%c",&select);
flushall();

while(select != 'e')
{
if(select=='a')
sum = a + b;
if(select=='b')
sum = a - b;
if(select=='c')
sum = a * b;
if(select=='d')
sum = a / b;

printf("/n %d",sum);
sum = 0;
}

}
printf("Continue : ( Y or N )");
scanf("%c",&choice);

}

No comments:

Post a Comment