Simple calculator Code for c++
here is the code:
#include <iostream>
#include <conio.h>
#include <string.h>
#include <windows.h>
#include <conio.h>
using namespace std;
int main()
{
int a;
float b,c,result;
restart:
cout<<"___________________________________\n";
cout<<" hello-code.blogspot.com\n";
cout<<"-----------------------------------";
cout<<endl<<endl<<endl;
cout<<"1. +"<<endl;
cout<<"2. -"<<endl;
cout<<"3. /"<<endl;
cout<<"4. *"<<endl;
cout<<"Enter the number : ";cin>>a;
system("cls");
cout<<"Enter your 1st number : ";cin>>b;
cout<<"Enter your 2nd number : ";cin>>c;
switch(a)
{
case (1):
result=b+c;
cout<<b<<" + "<<c<<" = "<<result;
break;
case (2):
result=b-c;
cout<<b<<" - "<<c<<" = "<<result;
break;
case (3):
result=b/c;
cout<<b<<" / "<<c<<" = "<<result;
break;
case (4):
result=b*c;
cout<<b<<" * "<<c<<" = "<<result;
break;
}
getch();
system("cls");
goto restart;
}
0 komentar:
Posting Komentar