Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if statement 1

Status
Not open for further replies.

jimjake

Technical User
Oct 30, 2004
25
US
int ans;
sstd::cout << "enter ans y/n";
std::cin >> ans;
if (ans == Y}
......
is there a way you can test for the small y and the caps Y in the same if statement.
 
Code:
if (ans=='Y'||ans=='y')
{
...
...
}


Go not to cats for advice for they will just walk over the keyboard
 
or use the function toupper (int c) which converts c to uppercase:

#include <stdlib.h>
#include <ctype.h>

...

if (toupper (ans) == 'Y')
{
...
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top