|
******************************************
Welcome To CrazyEngineers (CE) – an online community of engineers from all over the world! With the younger CEan at 84 and the youngest at 16, CE boasts of professional engineers, students, professors, entrepreneurs, CEOs, geeks & nerds. We exchange innovative ideas, share knowledge, help each other and expand our worldwide network of engineers! You need not have a formal degree in engineering to be a part of CrazyEngineers! Need we say more? Join CE! | Be a CE Ambassador! | Forgot password? | Sponsor CE | Contact Us |
![]() |
|
Good Administrator
![]() ![]() |
Puzzle Source: Cprogramming.com: C++ Programming Challenge - Guessing Game Challenge
The following program will act as a guessing game in which the user has eight tries to guess a randomly generated number. The program will tell the user each time whether he guessed high or low: Code:
#include <stdlib.h>
#include <iostream>
using namespace std; int main()
{
int number=rand()___;
int
guess=-1;
int trycount=0;
while(guess__number __ trycount<8)
{
cout__"Please enter a guess: ";
cin__guess;
__(guess_number)
cout<<"Too low"<<endl;
__(guess_number)
cout<<"Too high"<<endl;
_______________;
_
if(guess==number)
cout<<"You guessed the number";
____
cout<<"Sorry, the number was: "<<_____;
______
0;
Those who need spoon feeding, get the solution at the puzzle source.
__________________
-The Big K- Founder & Administrator ¤ The Big K’s Superblog™ ¤ About CE ¤ Small Talk ¤ CE Quick Start Guide for New Members ¤ Contact ¤ Buy CE GearNew |
|
|
|
| Sponsored links | |
|
|
|
|
Good Administrator
![]() ![]() |
I sit and wonder why we don't have a code cracker in our 18,000+ engineers' squad.
__________________
-The Big K- Founder & Administrator ¤ The Big K’s Superblog™ ¤ About CE ¤ Small Talk ¤ CE Quick Start Guide for New Members ¤ Contact ¤ Buy CE GearNew |
|
|
|
|
Good Administrator
![]() ![]() |
Ok, bayazidahmed - how about posting the solution and proving your point?
__________________
-The Big K- Founder & Administrator ¤ The Big K’s Superblog™ ¤ About CE ¤ Small Talk ¤ CE Quick Start Guide for New Members ¤ Contact ¤ Buy CE GearNew |
|
|
|
|
CE - Addict
![]() ![]() ![]() ![]() ![]() |
Quote:
__________________
Vinay Is Cool..ha ha ha |
|
|
|
|
|
CE - Regular Member
![]() ![]() ![]() |
Too bad, you should have tried compiling and posted your comments. It works perfectly fine for me. The syntax error you have pointed out will not come in any compiler. For your information, a single C/C++ statement can be spanned on multiple lines. The statement ends with a ; only. So, there is nothing wrong in writing int guess = -1 as int guess=-1 OR int guess=-1 OR int guess =-1 OR int guess = -1 |
|
|
|
| Sponsored links | |
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
| Contact Us - Home - Impressum | Impressum - |