• Log in or sign up for an account here: https://www.sythe.org/login

First guess my number program

IAmJerry

Active Member
Joined
Jun 29, 2010
Sythe Gold
0
Messages
214
First guess my number program
Made it from scratch, that's why i am proud of it (:.

Made it in Microsoft Visual C++ 2010.

Here it is

Edit: Well that kinda sucks looking at it now, but, i made a calculator last night, don't feel like putting it here though :).


#include <stdafx.h>



#include <iostream>
#include <cmath>


int main()
{
using namespace std;


float thenumber;
int mynumber = rand() % 100;


cout << "Guess my number.\n";

do {

cin >> thenumber;


if (thenumber > mynumber)

cout << "That number is too high." << endl;


else if (thenumber < mynumber)

cout << "That number is too low." << endl;

else

cout << "You got it!." << endl;

}
while ( thenumber != mynumber);

system("pause");
return 0;
}
 
First guess my number program
Good work :D

It doesn't suck, it's a great little program.

Here are two little tips though for your code.

Use a naming convention for variables. I prefer lower camel case, which is:
Code:
int theNumber;
double myDoubleVariable;

Second thing is, where you make a new line, you first use "\n", then everywhere after that you use "endl". Try to stick to using the same method, it makes your code cleaner and easier to read (especially in programs with a lot more code).
 
First guess my number program
You use \n in quotations when you're already using " "

examples...

cout << myNum << endl;
cout << "You guessed wrong\n";


and why are you using float then int? just use int
 
First guess my number program
used float b/c the number could've been a non perfect number

3.462

int is for perfect numbers only if i am not mistaken.

But besides that, i made a calc today, pretty proud of it :).
 
First guess my number program
used float b/c the number could've been a non perfect number

3.462

int is for perfect numbers only if i am not mistaken.

But besides that, i made a calc today, pretty proud of it :).

You should post it too, I'm interested in seeing it.
 
First guess my number program
Use double, not float; it stores a more reasonable amount of digits.
 
Runescape Gamblingrunescape gambling
Back
Top