my second C++ program

c, c++, php, html, sql ..etc discussion. also includes codes and source codes.
Post Reply
PinPoint
Special
Special
Posts: 126
Joined: Wed Dec 03, 2008 6:41 pm

my second C++ program

Post by PinPoint »

thought id post this one also. just finished it, little number guessing game. still going to do more like add option to give up and clues etc but im proud of this nonetheless even if noone else is :)

Code: Select all

/* This is my second ever program made by memory and trial and error.
Created by PinPoint on 22/11/2010 after a few hours learning C++ */

#include <iostream>
#include <cstdio>
using namespace std;

int main ()
{
    
    int number;
    int guess;
        
    number = (423);
    
    cout << "Press enter to Play My Game...\n";
         getchar();
    cout << "Guess the number equal to or higher\n"
         << "than 0 and equal to or smaller than\n"
         << "1000 and you will get a surprise\n\n";
                cout << "I think the number is = "; 
         cin >> guess;
             getchar();

restart1:  
               
               
                        
if (guess==number) 
{
   cout << "\n\nYOU'RE AWSOME!!!!!\n\n";
        getchar();
        cout <<"Goodbye and thanks for playing.\n";
}
                                   
else if (guess<number) 
{  
   cout << "\n\nYou're guess is lower\n\n\tI think the number is = ";
        cin >> guess;
        
        goto restart1;
            getchar();
}
else if (guess>number)
{
   cout << "\n\nYou're guess is higher\n\n\tI think the number is = ";
        cin >> guess;
        goto restart1;
            getchar();
}
    getchar();    
    return 0;
}

the game is attached for you all to try also
Attachments
guess the number game.rar
(104.71 KiB) Downloaded 630 times
Last edited by PinPoint on Mon Nov 22, 2010 8:57 pm, edited 1 time in total.
User avatar
Sethioz
Admin
Admin
Posts: 4762
Joined: Fri Jul 27, 2007 5:11 pm
Custom: Gaming YT > https://youtube.com/SethiozEntertainment
Game Hacking YT > https://youtube.com/sethioz
Game Hacks Store > https://sethioz.com/shopz
Location: unknown
Contact:

Re: my second C++ program

Post by Sethioz »

now make it randomize the number, so its never same.
PinPoint
Special
Special
Posts: 126
Joined: Wed Dec 03, 2008 6:41 pm

Re: my second C++ program

Post by PinPoint »

just need to change number = (423); to number (rand());
Post Reply