# include <iostream.h> # include <conio.h> # include <iomanip.h> void main() { float a,b,c,d; gotoxy(12,4); cout<<"WELCOME TO SIMPLE WALKYTALKY CALCULATOR !\a\n"; cout<<" MAIN MENU\n"; cout<<"1."<<" "<<"ADDITION\n"; cout<<"2."<<" "<<"SUBTRACTION\n"; cout<<"3."<<" "<<"MULTIPLICATION\n"; cout<<"4."<<" "<<"DIVISION\n"; cout<<"5."<<" "<<"SQUARE OF NUMBER\n"; cout<<"6."<<" "<<"FACTORIAL OF NUMBER\n"; cout<<"PRESS ANY KEY OF ABOVE NUMBERS\n"; cin>>c; cout<<"\a"; clrscr(); cout<<"\a"; if (c==1) {cout<<"ADDITION AREA\n"; cout<<"INPUT THE NUMBERS \n"; cout<<"ENTER NO.1\n"; cin>>a; cout<<"\a"; cout<<"ENTER NO.2\n"; cin>>b; cout<<"\a"; cout<<"ANSWER\n"; cout<<a<<"+"<<b<<"="<<a+b;} else if (c==2) {cout<<"SUBTRACTION AREA\n"; cout<<"INPUT THE NUMBERS\n"; cout<<"ENTER NO.1\n"; cin>>a; cout<<"\a"; cout<<"ENTER NO.2\n"; cin>>b; cout<<"\a"; cout<<"ANSWER\n"; cout<<a<<"-"<<b<<"="<<a-b;} else if (c==3) {cout<<"MULTIPLICATION AREA\n"; cout<<"INPUT THE NUMBERS\n"; cout<<"ENTER NO.1\n"; cin>>a; cout<<"\a"; cout<<"ENTER NO.2\n"; cin>>b; cout<<"\a"; cout<<"ANSWER\n"; cout<<a<<"*"<<b<<"="<<a*b;} else if (c==4) {cout<<"DIVISION AREA\n"; cout<<"INPUT THE NUMBERS\n"; cout<<"ENTER NO.1\n"; cin>>a; cout<<"\a"; cout<<"ENTER NO.2\n"; cin>>b; cout<<"\a"; cout<<"ANSWER\n"; cout<<a<<"/"<<b<<"="<<a/b;} else if (c==5) {cout<<"SQUARE AREA\n"; cout<<"INPUT A NUMBER\n"; cin>>a; cout<<"\a"; cout<<"SQUARE OF"<<" "<<a<<" "<<"IS"<<" "<<a*a;} else if(c==6) {int d=1; cout<<"FACTORIAL AREA\n"; cout<<"INPUT A NUMBER\n"; cin>>a; cout<<"\a"; for(b=a;b>=1;b--) {d=d*b;} cout<<"THE FACTORIAL OF"<<" "<<a<<" "<<"IS"<<" "<<d;} else {cout<<"ERROR !"<<" "<<c<<" "<<"NOT DEFINED IN ABOVE NUMBER";} getch(); }
C Program For Creating Simple Calculator
January 04, 2015
By:
Bhanu Namikaze
Bhanu Namikaze
Bhanu Namikaze is an Ethical Hacker, Security Analyst, Blogger, Web Developer and a Mechanical Engineer. He Enjoys writing articles, Blogging, Debugging Errors and Capture the Flags. Enjoy Learning; There is Nothing Like Absolute Defeat - Try and try until you Succeed.
No comments:
Post a Comment