Thursday, December 23, 2010

C++ Tutorial

I'm learning C++ this holiday :D

#include

using namespace std;

int main(int argc, char * const argv[])
{

//variable block

int yourAge;
int myAge = 1000000;

//main block
cout << "Hello, World!\n";

cout << "What is your age: ";
cin >> yourAge;
if (yourAge > myAge) {
cout << "Your " << (yourAge-myAge) << " years older than me." << endl;
}
else {
if (yourAge == myAge) {
cout << " You are the same age as me" << endl;
}
else {
cout << "Your " << (myAge-yourAge) << " years younger than me." << endl;
}
}
return 0;
}


No comments:

Post a Comment