Program to make a menu driven and reusable calculator

story_writer By story_writer, 24th Sep 2012 | Follow this author | RSS Feed | Short URL http://nut.bz/45028i8y/
Posted in Wikinut>Guides>Technology>Computer Software

This is a medium length program for converting a decimal number into octal number in c.

Program

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
long int i=1,a,b,c=0,choice=1;
clrscr();
do
{

switch(i)
{
case 1:
{
printf("enter numbers\n");
scanf("%ld%ld",&a,&b);
printf("enter 1 for add\n");
printf("enter 2 for subtract\n");
printf("enter 3 for multiply\n");
printf("enter 4 for divide\n");
printf("enter 5 for modulus\n");
printf("enter choice\n");
scanf("%d",&choice);
switch(choice)
{
case 1:c=a+b;
break;
case 2:c=a-b;
break;
case 3:c=a*b;
break;
case 4:c=a/b;
break;
case 5:c=a%b;
break;
default:printf("wrong input\n");
break;
}
if(choice>0&&choice<6)
printf("%ld",c);
break;
}
}
printf(" enter 1 for re using calculator\n");
printf(" enter other number for exit\n");
scanf("%ld",&i);
}while(i==1);
printf("thank you\n");
getch();
}

Tags

Menu, Menu Selections, Menus, Program, Programmes, Programming In C

Meet the author

author avatar story_writer
i blogs about programming and new stuff

Share this page

moderator Steve Kinsman moderated this page.
If you have any complaints about this content, please let us know

Comments

Add a comment
Username
Can't login?
Password