English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I wrote a programme of calculator in C language. And it has two or three error so pl do correct them. And send me correct answer.
Prog. is:

#include
#include
void calsum(int a,int b);
void calsub(int a,int b);
void calmul(int a,int b);
void caldiv(float a,float b);
/*void calmod(int a,int b); */
void calsqr(int a);
void calcue(int a);
void calfac(long int a);
void main()
{
int l,m,n,ch;
clrscr();
printf("\t\t==========\n");
printf("\t\t Menu ");
printf("\t\t==========\n");
printf("\t\t 1 Add\n");
printf("\t\t 2 Sub\n");
printf("\t\t 3 Mul\n");
printf("\t\t 4 Div\n");
printf("\t\t 5 Factorail\n");
printf("\t\t 6 Square\n");
printf("\t\t 7 Cube\n");
/*printf("\t\t 8 Mod\n"); */
printf("\t\t Enter your choice \n");
scanf("%d",ch);
printf("\t\t =====\t");
switch(ch)
{
case 1:
printf("\t\tEnter two number : ");
scanf("%d%d",&l,&m);
calsum(l,m);
break;
case 2:
printf("\t\tEnter two numbers " );
scanf("%d%d",&l,&m);
calsub(l,m);
break;
case 3:
printf("\t\t Enter two numbers" );
scanf("%d%d",&l,&m);
calmul(l,m);
break;
case 4:
printf("\t\t Enter two numbers : ");
scanf("%s%s",&l,&m);
caldiv(l,m);
break;
case 5:
printf("\t\t Enter any no : ");
scanf("%ld",&l);
calfac(l);
break;
case 6:
printf("\t\t Enter any no : ");
scanf("%d",&l);
calsqr(l);
break;
case 7:
printf("\t\t Enter any no : ");
scanf("%d",&l);
calcue(l);
break;
/*
case 8:
printf("\t\t Enter any no : ");
scanf("%d",&l);
calmod(l);
break;*/
default:
printf("\t It is wrong choice : ");
}
getch();
}
void calsum(int a,int b)
{
int c;
c=a+b;
printf("Addition=%d",c);
}
void calsub(int a,int b)
{
int c;
c=a-b;
printf("Substance=%d",c);
}
void calmul(int a,int b)
{
int c;
c=a*b;
printf("Multiply=%d",c);
}
void caldiv(float a,float b)
{
float c;
c=a/b;
printf("Divide=%d",c);
}
void calsqr(int a)
{
int c;
c=a*a;
printf("Square=%d",c);
}
void calcue(int a)
{
int c;
c=a*a*a;
printf("Cube=%d",c);
} /*
void calmod(int a,int b)
{
int c;
c=a%b;
printf("Mod=%d",c);
} */
void calfac(long int a)
{
long int i,fct;
fct=1;
for(i=a;i>=1;i--)
{
fct=fct*i;
}
printf("Factorail=%d",fct);
}

2006-10-18 12:23:00 · 1 answers · asked by Pushpendra 1 in Education & Reference Homework Help

1 answers

One error is that on this line:

scanf("%d",ch);

you need to put a & in front of ch.

2006-10-21 08:04:31 · answer #1 · answered by James L 5 · 0 0

fedest.com, questions and answers