The Most Active and Friendliest
Affiliate Marketing Community Online!

“Adavice”/  “1Win

A few C++ related questions

alphamedical

New Member
affiliate
I've been using C++ for about 1 - 2 hours, and I've got a small program built but I'd like it checking over to see if I'm coding right - before I start getting used to bad syntax or whatever
PHP Code:
#include <iostream>
#include <string>
using namespace std;

int main()
{
int age, feet, inches, pounds;
string hair, eye, correct;

cout << "Please type your answer to each question"
<< " followed by <enter>:" << endl;
cout << "What is your age (years)? ";
cin >> age;
cout << "\nHow tall are you (ft in)? ";
cin >> feet >> inches;
cout << "\nHow much do you weigh (lbs)? ";
cin >> pounds;
cout << "\nWhat colour is your hair? ";
cin >> hair;
cout << "\nWhat colour are your eyes? ";
cin >> eye;

cout << endl << "\nYou are "<< age <<" years old, "
<< feet << " feet " << inches << " inches tall."
<< "\nYou weigh "<< pounds <<" pounds,"
<< " have "<< hair <<" coloured hair and "
<< eye << " coloured eyes." << endl;

cout << "\nIs this correct? ";
cin >> correct;
if (
correct == "yes"){
cout << "\nThank you" << endl;
}else{
cout << "\nWell it's what you put in..." << endl;
}
return
0;
}

Also, I noticed something called vector on one site. What is this?

Also, at the end of the program, the window closes before I get a chance to see what the end result says (although I know myself what it is, others won't).

Another thing, how can I make the answer yes case insensitive, so ppl can answer YeS and still get the Thank you message?
 
banners
Back