I am new to programing and just want to share my first very small guess a number program and get some suggestion on it. There is one other thing I am using Bloodsheed Dev C++ and it come up with these errors at the bottom of the screen when compling but the .exe still works fine
Code:
////////////////////////////////////////////////////////////////////////////////
//
// langue C++
// Pogram Computer generates number and user trys to guess it
//
////////////////////////////////////////////////////////////////////////////////
#include <iostream.h> //Main include basic funcitions
#include <string.h> //For use of stings
#include <stdio.h> //??????
int main()
{
int number; //"number" variable use to save the users number
int answer; //"answer" variable use to save if the player wants to try agin 1=Yes 2=No
int round; //"round" variable use to save how many times the player has tryed to gues there is only 5 chances
char name[20]; //"name" is a string that saves the players name and makes the game more customized
int r; //"r" variable is the number that the user is tring to guess
r=rand()%11; //Changes the value of 'r" at random
////////////////////////////////////////////////////////////////////////////////
//
// Cheat Codes
//
////////////////////////////////////////////////////////////////////////////////
{
round=0; //Sets the veriable "round" to 0
cout<<"What is your name: "; //Ask the user to input there name
cin.getline(name, 20, '\n'); //Saves the user input in the variable "name"
if(!strcmpi("Beta", name)) //Tells the computer that if the user input is "Beta" then do the code below it
{
r=5; //Sets the veriable "r" to 5
}
if(!strcmpi("Loser", name)) //Tells the computer that if the user input is "Loser" then do the code below it
{
cout<<"Sorry, "<<name<<" ,no cheating for you. By the way did you chose this name. "; //Prints the texts in "
cin.get (); //Tells the computer to wait until the user to press enter to run the next line of code
return 0; //Tells the computer to end the program
}
}
////////////////////////////////////////////////////////////////////////////////
//
// Guess the Number part
//
////////////////////////////////////////////////////////////////////////////////
do //Tells the computer to do what is blow this if while = what you have put in
{
round++; //Adds 1 to the veriable "round"
cout<<"I am think of a number between 1-10 what is it: ";
cin>>number;
if(number==r)
{
cout<<"Congradulations, "<<name<<" ,you got it right!!!";
cin.get ();
answer=2;
}
else if(number>r)
{
cout<<"1=Yes 2=No"<<endl<<endl<<"Sorry, "<<name<<" ,it was a little to high. Would you like to try agin: ";
cin>>answer;
}
else if(number<r)
{
cout<<"1=Yes 2=No"<<endl<<endl<<"Sorry, "<<name<<" ,it was a little to low. Would you like to try agin: ";
cin>>answer;
}
if(round==5)
{
answer=2;
cout<<"Sorry, "<<name<<" ,that was your last try the answer was "<<r;
cin.get ();
}
}
while (answer==1);
cin.get ();
return 0;
}
The .exe is attached to the post. Feed back would be apceated.