Contents covered: queues,Stacks,Arrays,Strings,Trees little concepts of loops and conditional statements. All of this is data structure also known as OOP. classes and structure also used in programms randomly. c++ all concepts will reaptidly shown here
Tuesday, October 30, 2018
Number Guessing Game
// number gussing game
#include<iostream>
#include <cstdlib>
#include<ctime>
using namespace std;
main()
{ // decleration of veriable
int num;
int guess;
bool isGuessed;
num = (rand() + time(0))% 100;
isGuessed = false;
cout<<"\n\t\tNumber Guessing Game"<<endl;
while (!isGuessed)
{
//cout<<"_______________________________________________________________________________"<<endl;
cout << "Enter an integer greater than or equal to 0 but less than 100: " ;
cin >> guess ;
cout << endl;
if (guess==num)
{
cout<<"************************************************************"<<endl;
cout << "\n\tCONGRATULATION! you guess the correct number \n." << endl;
cout<<"************************************************************"<<endl;
isGuessed=true;
}
else if (guess<num)
{
cout<<"Ooooopps1!\n\n YOUR GUESS IS LOWER THAN THE NUMBER.\n\n TRY AGAIN :)" << endl;
cout<<"_______________________________________________________________________________"<<endl;
}
else
{
cout << "Oh! YOUR GUESS IS HIGHER THAN THE NUMBER.\n\n "<< "GUESS AGAIN :)" << endl;
cout<<"_______________________________________________________________________________"<<endl;
}
}
return 0;
}
Subscribe to:
Post Comments (Atom)
this is interesting
ReplyDeletewhat is the purpose of rand() and time()
ReplyDeleterand() will genrate a number an arbitrary number.
ReplyDeletetime() shows time in nano seconds according to your time calender