BCS-1A

Tuesday, January 17, 2012

Guessing Game


#include <iostream>
#include <conio.h>
#include <stdio.h>
#include <time.h>

using namespace std;
void wait ( int seconds )
{
  clock_t endwait;
  endwait = clock () + seconds * CLOCKS_PER_SEC ;
  while (clock() < endwait) {}
}

int main ()
{
    int guess,
        n;
      printf ("Loading Game Please wait...\n");
  for (n=9; n>0; n--)
  {
    printf ("           %d\r",n);
    wait (1);
  if(n == 1)
  system ("CLS");
  }
cout << "        Welcome to Guessing a number Game"<< endl << endl;
while (guess != 92)
{
cout << "        Guess any number from (0-100)  : ";
cin >> guess;

if (guess == 92 )
cout << "          You Guess the Correct number.";
else if (guess > 92 )
cout<<"   Your Guessed number is Greater than correct number.\n"
    <<"                  Try again...\n\n\n";
else if (guess < 92 )
cout<<"   Your Guessed number is Less than correct number.\n"
    <<"                  Try again...\n\n\n";
else
cout <<"             You enter invalid number..";
}// end of while loop

cout <<"\n\n\n\n\n\n\n\n\n\n\n"
     <<"         "
     <<"Created By:Mohammad Hussnain Imtiaz";
getch();
return 0;
}// end of main function

No comments:

Post a Comment