#include "stdafx.h"
#include<iostream>
using namespace std;
void main()
{
float n1,n2,s;
char ch;
cout<<"ENter the values"<<endl;
cin>>n1;
cout<<"ENter the operator"<<endl;
cin>>ch;
cout<<"ENter the 2nd values"<<endl;
cin>>n2;
switch(ch)
{
case '+':
s=n1+n2;
break;
case '-':
s=n1-n2;
break;
case '*':
s=n1*n2;
break;
case '/':
s=n1/n2;
break;
default:
cout<<"invalid character "<<endl;
}
if (ch=='+'||ch=='-'||ch=='*'||ch=='/')
cout<<n1<<ch<<n2<<"="<<s<<endl;
system("pause");
}
No comments:
Post a Comment