Sunday, May 10, 2009

C programme...?

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%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;


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",%26amp;l,%26amp;m);


calsum(l,m);


break;


case 2:


printf("\t\tEnter two numbers " );


scanf("%d%d",%26amp;l,%26amp;m);


calsub(l,m);


break;


case 3:


printf("\t\t Enter two numbers" );


scanf("%d%d",%26amp;l,%26amp;m);


calmul(l,m);


break;


case 4:


printf("\t\t Enter two numbers : ");


scanf("%s%s",%26amp;l,%26amp;m);


caldiv(l,m);


break;


case 5:


printf("\t\t Enter any no : ");


scanf("%ld",%26amp;l);


calfac(l);


break;


case 6:


printf("\t\t Enter any no : ");


scanf("%d",%26amp;l);


calsqr(l);


break;


case 7:


printf("\t\t Enter any no : ");


scanf("%d",%26amp;l);


calcue(l);


break;


/*


case 8:


printf("\t\t Enter any no : ");


scanf("%d",%26amp;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%26gt;=1;i--)


{


fct=fct*i;


}


printf("Factorail=%d",fct);


}

C programme...?
/*Simple Calculator*/





#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;


void main()


{


int a,b,C;


char ch;


clrscr();


printf("Enter any two numbers:\n");


scanf("%d%d",%26amp;a,%26amp;b);


printf("The operation to be performed is: \n");


fflush(stdin);


scanf("%c",%26amp;ch);


switch(ch)


{


case '+':


C=a+b;


break;


case '-':


C=a-b;


break;


case '*':


C=a*b;


break;


case '/':


C=a/b;


break;


default:


printf("character is invalid");


}


printf("Answer is %d",C);


getch();


}





/* Output */





Enter any two numbers:


24 2


Enter any character


/


Answer is 12


No comments:

Post a Comment