Menu driven program to do simple arithmetic operations in C.

c-techaravind


                                              To compile and execute the program, copy the code into a text file. Save the text file with the extinction .c (ex. program.c). Save your file in turboc2 or borland (it may your othe c-compiler). Now open you IDE (tc.exe) , goto file->pick file. Your source file will be loaded into IDE. Now you can compile and run the file easily.






#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,ch;
float result;
do
{
clrscr();
 gotoxy(31,1);
printf("Arthmatic Menu");
gotoxy(26,3);
printf("www.techaravind.blogspot.com");
gotoxy(1,5);
printf("select the operation from list");
printf("\n 1.ADDITION \n 2.SUBSTRACTION");
printf("\n 3.MULTIPLICATION \n 4.DIVISION");
printf("\n 4.exit\n" );

printf("\n Enter your choice:");
scanf("%d",&ch);
}
while((ch>4)||(ch<1));
switch(ch)
{
case 1:
 printf("\n enter two numbers:");
scanf("%d%d",&a,&b);
result=a+b;
printf("\n result=%f",result);
break;
case 2: printf("\n enter two numbers:");
scanf("%d%d",&a,&b);
result=a-b;
printf("\n result=%f",result);
break;
case 3: printf("\n enter two numbers:");
scanf("%d%d",&a,&b);
result=a*b;
printf("\n result=%f",result);
break;
case 4: printf("\n enter two numbers:");
scanf("%d%d",&a,&b);
result=a/b;
printf("\n result=%f",result);
break;
case 5:
exit(0);
}
getch();
}

0 comments:

Post a Comment

 
Etutos © 2010-2011