calculator Posted on 05:44 by Unknown Calculator Program Code: #include #include #include void showcalculator(void); void showcalculator(){ long double fact=1; float a,b,choice,r; char op; clrscr(); printf(" "); printf("\n "); printf("\n "); printf("\n "); printf("\n_______________________________________"); printf("\n* *"); printf("\n****************************************"); printf("\n* *"); printf("\n* *"); printf("\n* *"); printf("\n****************************************"); printf("\n* *"); printf("\n* 1 2 3 + oct hex *"); printf("\n* *"); printf("\n* 4 5 6 - sin cos *"); printf("\n* *"); printf("\n* 7 8 9 * tan n! *"); printf("\n* *"); printf("\n* 0 . = / log x^2 *"); printf("\n* *"); printf("\n* MC MR M+ inv Deg Rad *"); printf("\n* *"); printf("\n****************************************"); printf("\n*______________________________________*"); gotoxy(2,8); scanf("%f",&a); gotoxy(2,8); op=getch(); if(op=='+' || op=='-' || op=='/' || op=='*') { gotoxy(2,8); scanf("%f",&b); } switch(op) { case 'f': { while(a>1) { fact=fact*a; a=a-1; } gotoxy(2,10); printf("%.2Lf",fact); } break; case'h': printf("\n%x",(int)a); break; case'o': printf("\n%o",(int)a); break; case 'q': r=sqrt(a); printf("\nSquare Root = %.4f",a,r); break; case 'c': a=a*3.141592/180; r=cos(a); printf("\nCos(%.4f) = %.4f",a,r); break; case 's': a=a*3.141592/180; r=sin(a); printf("\nSin(%.4f) = %.4f",a,r); break; case 't': a=a*3.141592/180; r=tan(a); printf("\nTan(%.4f) = %.4f",a,r); break; case'+': { r=a+b; gotoxy(19,10); printf("%.3f" ,r); break; } case'-': r=a-b; gotoxy(19,10); printf("%.3f" ,r); break; case'*': r=a*b; gotoxy(19,10); printf("%.3f" ,r); break; case'/': r=a/b; gotoxy(19,10); printf("%.3f" ,r); break; default: printf("Syntax Error"); break; } } void main(){ int choice; //int a=1; while(1) { showcalculator(); gotoxy(35,35); printf("Prs Enter to EXIT"); scanf("%c",&choice); if (choice=='n') { // a=0; } break; } getch(); } This entry was posted in Programs
0 comments:
Post a Comment