if with char

Started by
1 comment, last by Malachi 22 years, 1 month ago
Thanks to a few people I got the main part of my code done for looping,now Im in my final stages in completing my program. Ive come across a small problem.This is a sample of my program, #include <iostream.h> int tables(); int a; char answer; int main() { do{ cout <<"which table would you like me to multiply? "; cin >> a; }while (a>20); tables(); } int tables() { cout <<"\n1X" << a << "=" << a*1; cout <<"\n2X" << a << "=" << a*2; cout <<"\n3X" << a << "=" << a*3; cout <<"\n4X" << a << "=" << a*4; cout <<"\n5X" << a << "=" << a*5; cout <<"\n6X" << a << "=" << a*6; cout <<"\n7X" << a << "=" << a*7; cout <<"\n8X" << a << "=" << a*8; cout <<"\n9X" << a << "=" << a*9; cout <<"\n10X" << a << "=" << a*10; cout <<"\n11X" << a << "=" << a*11; cout <<"\n12X" << a << "=" << a*12; cout <<"\nwould you like me to multiply another number Y/N? "; cin >> answer; if ( answer == "Y") return 0; } What Im trying to do is, if the user enters Y then I want the program to loop from the start. But I keep on getting errors with "if ( answer == "Y")" , can someone help me out please?
Advertisement
answer is of type char, "Y" is a cstring. Use ''Y'' instead.
Thanks

This topic is closed to new replies.

Advertisement