+ 1

Could anyone tell me why the following code gives errors? I want to test if the letter entered is (a)then the result is true.?

#include <iostream> using namespace std; int main() { char letter; cin>>letter; if(letter==a) cout<<"your letter is a"; return 0; }

8th Sep 2017, 10:30 AM
RiGeL
RiGeL - avatar
2 Respuestas
+ 4
You need to surround the a in your if condition in single quotes to make it a char. if(letter=='a')
8th Sep 2017, 10:50 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
@ChaoticDawg thank you alot
8th Sep 2017, 11:19 AM
RiGeL
RiGeL - avatar