C Program For Creating Simple Calculator

# 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();
}

Bhanu Namikaze

Bhanu Namikaze is an Ethical Hacker, Web Developer, Student and Mechanical Engineer. He Enjoys writing articles, Blogging, Solving Errors and Social Networking. Feel Free to let me know any of your concerns about hacking or let me know if you need any more methods on hacking anything. Enjoy Learning

No comments:

Post a Comment