Add to Favorites    Make Home Page 21028 Online  
 Language Categories  
 Our Services  

Home » C++ Home » Algorithms Home » calculater

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title calculater
Author saurabh singh naruka
Author Email cricket_naruka [at] yahoo.co.in
Description SIMPLE CALCULATOR
Category C++ » Algorithms
Hits 372813
Code Select and Copy the Code
Code : // Simple Calculator // // By: saurabh singh // // M.C.A. MAISM, jaipur // // Can have many Flaws // #include"stdio.h" #include"conio.h" #include"dos.h" #include"stdlib.h" #include"string.h" void DISPNUM(char *); void main() { clrscr(); _setcursortype(0); gotoxy(30,19); textcolor(GREEN+BLINK); cprintf("SIMPLE CALCULATOR"); gotoxy(50,21); textcolor(BLUE+BLINK); cprintf("By Rakesh Juyal"); getch(); // clrscr(); int x=30,y=10; textcolor(WHITE); gotoxy(x,y); cprintf("7 8 9"); gotoxy(x,y+2); cprintf("4 5 6"); gotoxy(x,y+4); cprintf("1 2 3"); gotoxy(x,y+6); cprintf("0"); textcolor(RED); gotoxy(x+5,y+6); cprintf(". ="); textcolor(GREEN); x=x+15; gotoxy(x,y); cprintf("/"); gotoxy(x,y+2); cprintf("*"); gotoxy(x,y+4); cprintf("-"); gotoxy(x,y+6); cprintf("+"); //Draw The For Calc// x=28;y=5; gotoxy(x,y); textcolor(WHITE); // ? & ? // cprintf("%c",218); gotoxy(28+20,y); cprintf("%c",191); // ? & ? // //Horiz. Boundary for(x=29;x<=28+19;x++) { gotoxy(x,y); cprintf("%c",196); gotoxy(x,y+12); cprintf("%c",196); } //End of Horiz. Bound // ? & ? // cprintf("%c",217); x=28;y=y+12; gotoxy(x,y); cprintf("%c",192); //End of ? & ? // //Vertic. Bound. for(y=6;y<=16;y++) { gotoxy(x,y); cprintf("%c",179); gotoxy(x+20,y); cprintf("%c",179); } //End of Vertic Bou. y=6; for(x=30;x<=30+16;x++) { gotoxy(x,y); cprintf("%c",196); gotoxy(x,y+2); cprintf("%c",196); } gotoxy(30,y+1); cprintf("%c %c",179,179); gotoxy(30,y); cprintf("%c",218); gotoxy(30+16,y); cprintf("%c",191); gotoxy(30,y+2); cprintf("%c",192); gotoxy(30+16,y+2); cprintf("%c",217); //End of Vertic Bound. //OutPut at X=30,Y=8// char ch; char operand1[15]="",operand2[15]="",BLANK[15]=" "; char operator1,first='y'; long double num1=0,num2=0; int i=0,ERROR=0; //Digits int MAX=10; DISPNUM(0); do { ch=getch(); if(ch=='x1b') { for(int i=1000;i>=200;i=i-50) { sound(i); delay(100); } nosound(); break; } //Numeric// if((ch>='0')&&(ch<='9')) { if(i<MAX) { if(first=='y') { operand1[i]=ch; DISPNUM(operand1); i++; } else { operand2[i]=ch; DISPNUM(operand2); i++; } } else //More than 8 digit { ERROR=1; } } else if(ch=='.') { if(first=='y') { if(strchr(operand1,'.')==NULL) { operand1[i]=ch; i++; } DISPNUM(operand1); } else { if(strchr(operand2,'.')==NULL) { operand2[i]=ch; i++; } DISPNUM(operand2); } } //Non Numeric else if (ch=='*') { operator1='*'; first='n'; i=0; } else if (ch=='/') { operator1='/'; first='n'; i=0; } else if (ch=='+') { operator1='+'; first='n'; i=0; } else if (ch=='-') { operator1='-'; first='n'; i=0; } else if ((ch=='=')||(ch==' ')) { //Store in Floating if(strcmpi(operand1,BLANK)!=0) { num1=_atold(operand1); } if(strcmpi(operand2,BLANK)!=0) { num2=_atold(operand2); } //Now Calculate switch (operator1) { case '+': num1=num1+num2; break; case '-': num1=num1-num2; break; case '*': num1=num1*num2; break; case '/': num1=num1/num2; break; } //ltoa(num1,operand1,10); gcvt(num1,12,operand1); DISPNUM(operand1); i=0; first='y'; strcpy(operand1,BLANK); strcpy(operand2,BLANK); } else //Invalid Choice { ERROR=1; } //Beep On ERROR else ------ // if (ERROR==0) { sound(920); } else { sound(100); ERROR=0; } delay(250); nosound(); gotoxy(1,1); cprintf("%d",i); }while(1); // clrscr(); gotoxy(30,19); textcolor(GREEN+BLINK); cprintf("SIMPLE CALCULATOR"); gotoxy(50,21); textcolor(BLUE+BLINK); cprintf("By Rakesh Juyal"); // getch(); } void DISPNUM(char *num) { textbackground(RED); gotoxy(31,7); cprintf(" "); gotoxy(31,7); cprintf("%s",num); }

Related Source Codes

Script Name Author
Moving ball screen saver karlmarx
The Classic Game of Snake & Ladder Lakshmi Narayana .A
Railway seat reservation question which comes in sapient VyomWorld
To calculate percentile Ravi Mathur
Send to folder ANIMESH SAHU
Analog clock and calendar Nazia & Rida
HIGH/LOW GAME MOLLY ARORA
Data structure (stack Implimentation) Swapnil B Adsure
Memory Game AnirudhSanyal
Easy Calc Anirudh Sanyal
GK Quiz Anirudh Sanyal
Hangman Game Manish Jain
Snakeman Manish Jain
Full month Calendar Nigi
Cursor shapes nigi

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:

Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions | Important Websites
Copyright ©2003-2024 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=1013


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review