Author Topic: Learning C++! :D  (Read 3680 times)

A is a character
yourAnswer is an integer
oh
im guessing change a b and c to 1 2 and 3 wont help

put "char" before yourAnswer instead of int, see if that helps.

A variable declaration is something like 'int varA;' - you're telling the program to make space in memory for a variable named varA
If a variable is undeclared it means you didn't do that.


Change 'int yourAnswer;' to 'char yourAnswer;'
Change if(yourAnswer == A) to if(yourAnswer == 'A') and similar for the other two ifs.
« Last Edit: September 04, 2011, 05:11:09 PM by Headcrab Zombie »


ugh

well it compiles now
but it doesnt work right



Quote
#include <iostream>
int main()                 //what the heck help me aaaaaaa
{
    using namespace std;

    char yourAnswer;
    cout << "Jim says: Hi!   Enter your answer: \n";
    cout << "\nA. Hello, what's your name?\n";
    cout << "\nB. Um... hi.\n";
    cout << "\nC. Go away.\n";
    cin >> yourAnswer;
    if (yourAnswer == 'A')
        cout << "\nMy name is Jim.\n";
    if (yourAnswer == 'B')
        cout << "\nHello.\n";
    if (yourAnswer == 'C')
        cout << "\nUm... okay.\n";

    return 0;
}
heres the code

if (yourAnswer == 'a')

Use lower case letters. I forget if it's actually case sensitive but I'm betting it is so try that.

What do you use to complile?

What do you use to complile?
Code::Blocks
use it to edit and compile

if (yourAnswer == 'a')

Use lower case letters. I forget if it's actually case sensitive but I'm betting it is so try that.
THANKYOUTHANKYOU
IT WORKS :D

added the JimHello program into the op

oh dang need to update my tumblr with the JimHello program


I know visual basic and a tiny bit of TorqueScript.