Thread: C++ quick bit of help needed will take less than a minute i promise!
not quite sure doing there following tutorials , trying change stuff go. need line 8code:#include <iostream> using namespace std; int main() { int age = ( 2011 - dob ); //its doing wrong? int dob; cout<<"please enter date of birth: "; cin>> dob; cin.ignore(); if ( age < 100 ){ cout<<"you young!\n"; } else if ( age == 100 ) { cout<<"you old!\n"; } else { cout<<"you old!\n"; } cin.get(); }
you using dob variable before declaring , initializing it.
moving line 8 after cin.ignore() solve problem.
Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk C++ quick bit of help needed will take less than a minute i promise!
Ubuntu
Comments
Post a Comment