این برنامه ی ماشین حساب به زبان سی پلاس پلاس است...
#include<stdio.h> #include<PROCESS.H> #include<conio.h> #include<iostream.h> int sum(int,int); int sub(int,int); int div(int,int); int mult(int,int); int ans(int); void show(); //******** ********* ****** ****** ****** ******* ****** void main() { int n,m,i; char ch; char answ; textcolor(4); textbackground(1); clrscr(); while(1) { //******************************************/ window(10,5,12,18); textcolor(4); textbackground(14); clrscr(); cprintf(" \n*\n\r +\n\r -\n\r /\n ~~~ \n\r C\n\n\rAns " ); //************************** window(26,5,26,16); textcolor(4); textbackground(14); clrscr(); //*********************/ window(14,16,30,7); textbackground(14); clrscr(); //************************ window(13,5,25,11); textbackground(14); clrscr(); //***************************** window(10,17,26,18); textbackground(14); clrscr(); //*********** safe kelid ************ window(13,11,25,18); textbackground(2); textcolor(0); cprintf(" 1 2 3 "); cprintf( "\r 4 5 6 "); cprintf( "\r 7 8 9 "); //********************************* window(13,6,25,8); textbackground(5); textcolor(7); clrscr(); //***************************** cin>>n>>ch>>m; if((ch=='+')||(ch=='-')||(ch=='/')|| (ch=='*')) { switch(ch) { case'+': cout<<"\t\t"<<"="<<sum(n,m); ans(sum(n,m)); getch(); cout<<ans(sum(n,m)); break; case'-': cout<<"\t\t"<<"="<<sub(n,m); ans(sub(n,m)); getch(); break; case'*': cout<<"\t\t"<<"="<<mult(n,m); ans(mult(n,m)); getch(); break; case'/': cout<<"\t\t"<<"="<<div(n,m); ans(div(n,m)); getch(); break; } } else if(ch=='q') exit(0); } } int sum(int x,int y) { return x+y; } int sub(int x,int y) { return x-y; } int div(int x, int y) { return (x/y); } int mult(int x, int y) { return (x*y); } int ans(int temp) { int answ[5],i=0; if(i<=5) answ[i++]=temp; else if(i>5) { cout<<"\n\tans is full...\n\tpress any key to remove the one Alocation..."; getch(); i=1; } } |