-
Very Basic c++ question
Hey guys i'm a complete beginner in c++. I'm interested in it from a game dev point of view but am trying to get my head around the basics at the moment.
Iv been following the tutorials and im just trying my own little statements to see if i can get them to work. I have copied some of the stuff from the tutorial and it worked fine.
ok, this is one i got to work so far
Code:
#include <iostream>
using namespace std;
int main()
{
if ( 5<10)
cout<<"five is less than 10";
}
That seem to be fine , working ok.
Then i tryed to say if 11 was less than 10 say it was false and then go to if 5 was less than 6 say it was true.
Anyone know how i could say this? I cant really figure out how to, thanks :)
-
>Then i tryed to say if 11 was less than 10 say it was false and then go to if 5 was less than 6 say it was true
Code:
if(11<10)
cout<<"false";
else if(5<6)
cout<<"true";
-
Thanks
i was trying this but im getting an error
Code:
if ( 1 == 2 ) {
cout<<"1 is equal to 2";
}
else
{
cout<<"1 is not equal to 2";
}
What am i doing wrong here?
I am using code block to try these out, if i was using visual basic are all the rules and syntax still the same?
-
-
i got two errors, maybe i have the curleys in the wrong place?
error: expected initializer before 'if'|error: expected unqualified-id before 'else'|
||=== Build finished: 2 errors, 0 warnings ===|
-
Post the smallest and simplest program that demonstrates the error.
-
The problem is its not a program - try this:
(I spent ages in a similar spot just last week)
Code:
#include <iostream>
using namespace std;
int main(){
if ( 1 == 2 ) {
cout<<"1 is equal to 2";
}
else
{
cout<<"1 is not equal to 2";
}
}
B.
-
This works as expected.
Did you copy and paste whatever was in your editor?
Also, since you are a beginner, take some time to look into proper indentation.