Need Teachers = )

Hi People =D , i'm new to C++ and i need help ..
i'm trying to finish my assignment but i don't know how to finish it -P

I need to make a project that do these .
-It asks the user to guess your favorite number.
-If the user guesses the right number, it tells them they got it right.
-The program doesn't have to do anything if the user guesses wrong.

i'm using Microsoft Visual C++ 2008 Express .

Need help . Thanks . Frice
We are not just going to do your homework for you... How about you post what you have done in the program so far and then we can have a look at it.
um well , yeah of cause . but how do you post pic here ? . sry new to Forum to

// Favorite Number , Annon



// Include the iostream library

#include <iostream>



//Use the standard namespace

using namespace std;



void main ( )

{

// Declare the variables

float Number_1 =7;

float Result;

int Which_Calculation = 1;
// Give Instructions

cout << "Hello can you guess Annon's favorite number?" << endl;

cin >> Which_Calculation;

// Print the answer is...

cout << "The answer is..." << endl;



//Print the result

cout << Result << endl;
system ("PAUSE");



}

well , this is probably it.
Don't really know what i'm doing here .
void main ( )

{

// Declare the variables

float Number_1 =7;

float Result =7;

int Which_Calculation = 1;
// Give Instructions

cout << "Hello can you guess Shawn's favorite number?" << endl;

cin >> Number_1;

// Print Text

cout << "That is amazingly correct!" << endl;

system ("PAUSE");



}

I edited part of it .
hi,
from what i understand you only have to check wether a user entered the correct number or not.

this you can do with an if statement:

if (TRUE) {execute all statements inside the braces}

you will need to use "relational operators" to check certain conditions are true or not.
in your case the "== equal to" relational operator should do.

i also suggest you use more speaking variable names to make things easier to read for yourself:

here is a solution that works:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
int main()
{

    // Variables:
    int secretNumber = 7;  
    int userguess;

    // instructions:

    cout << "Hello can you guess Shawn's favorite number?" << endl;

    // recieve input from user:

    cin >> userguess;

    // now here is where you need to check the conditions
    // you want to decide what ur program will answer
    // Checking condition:

    if (userguess == secretNumber) // did user guess correct?
    {
        cout << "That is amazingly correct!"<<endl;
    }

    // or did he guess wrong?

    else
    cout << "not true!"; // from your description of the task this is not needed.

    return 0;
}

Topic archived. No new replies allowed.