i am just a beginner and dont know a lot about c++ . i was trying to create a program which will prompt u to do addition or substraction
here is the code
# include <stdio.h>
# include <iostream>
usingnamespace std;
char response ;
int main()
{
int a,b,c,d,e;
cout << " would u like too do addition or substraction?"<<endl;
cout << " press 1 for add n 2 for subtract " << endl;
cin>> response ;
if (response >=1 )
{ cout <<" enter ur first digit " <<endl;
cin >> a ;
cout << " enter ur second digit"<< endl;
cin>> b;
cout << " the ans is " << (a+b) << endl;}
elseif (response >=2)
{
cout <<" enter ur first digit " <<endl;
cin >> a ;
cout << " enter ur second digit"<< endl;
cin>> b;
cout << " the ans is " << (a-b) << endl;
}
scanf ("%d%",&e);
return 0;
}
i am sure i have messed up a lot..if i press 1 it does addition if i press 2 it does addition ?? plz help?
ok lets forget (response <=1)
if i write (response==1)
n (response ==2)
and compile and then execute it i get a screen where i am told to enter 1 or 2
even if i enter 1 nothing happens and the same with 2