Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Malachi

if with char

This topic is 6113 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
answer is of type char, "Y" is a cstring. Use ''Y'' instead.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!