Started c++ a week ago, and this is so far the biggest thing I've accomplished with it so far.
Ideas for helping me to improve are always accepted![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
Ideas for helping me to improve are always accepted
Code:
#include <iostream>
#include <ctime>
#include <windows.h>
using namespace std;
int main ()
{
keybd_event(VK_MENU,0x36,0,0);
keybd_event(VK_RETURN,0x1c,0,0);
keybd_event(VK_RETURN,0x1c,KEYEVENTF_KEYUP,0);
keybd_event(VK_MENU,0x36,KEYEVENTF_KEYUP,0);
int age;
int rlage;
string p;
cout << "Please enter your age: ";
cin >> age;
if ( age < 40 ) {
cout << "You are pretty young!\n\n";
}
else if ( age > 41 ) {
cout << "You are getting old\n\n";
}
cin.get();
cout << "Wanna play guess the number!?!?! (y/n): ";
getline (cin, p);
if (p == "n") {
return 0; }
else {
system("CLS");
cout << "Ok!!!\n";
cout << "Loading.\n";
Sleep(500);
system("CLS");
cout << "Ok!!!\n";
cout << "Loading..\n";
Sleep(500);
system("CLS");
cout << "Ok!!!\n";
cout << "Loading...\n";
Sleep(500);
system("CLS");
cout << "Ok!!!\n";
cout << "Loading....\n";
Sleep(500);
system("CLS");
cout << "Ok!!!\n";
cout << "Loading.....\n";
Sleep(500);
system("CLS");
cout << "Ok!!!\n";
cout << "Loading.\n";
Sleep(500);
system("CLS");
cout << "Ok!!!\n";
cout << "Loading..\n";
Sleep(500);
system("CLS");
cout << "Ok!!!\n";
cout << "Loading...\n";
Sleep(500);
system("CLS");
cout << "Ok!!!\n";
cout << "Loading....\n";
Sleep(500);
system("CLS");
cout << "Ok!!!\n";
cout << "Loading.....\n";
Sleep(500);
}
system("CLS");
srand((unsigned)time(0));
int random_integer;
int lowest=1, highest=1000;
int range=(highest-lowest)+1;
random_integer = lowest+int(range*rand()/(RAND_MAX + 1.0));
rlage = random_integer;
cout << "Guess the number between 1 and 1000: ";
do
{
cin >> age;
if ( age <= rlage ) {
cout<<"Your cold, keep guessing\n";
}
else if ( age > rlage ) {
cout<<"Your going to high, keep guessing\n";
}
else if ( age == rlage ) {
cout<<"Well done! You guessed correctly\n";
}
} while (age != rlage);
return 0;
}