-
Total Newbie Question
Hey, this is slightly embarrassing.
I'm a complete newbie and most will probably laugh when you see my question or something, i'unno. Anyway, basically, I'm trying to learn C++ and I've just started today, learning about variables and some simple calculation stuff, so I decided to try making a simple program to see if I knew how to use what I learnt, so I tried this:
Code:
#include <iostream>
using namespace std;
int main()
{
int Adj = 10;
float Opp = 12.662;
float Hyp = Opp + Adj;
cout << "The hypoteneuse is" << Hyp << ;
return 0;
}
I'm not really sure about the return 0, I figured I just better put it there. The compiler says that in Line 10 (the cout one), expected primary expression before ";" token? I don't know :s
If anyone can help, that'd be appreciated...
-
Change this:
Code:
cout << "The hypoteneuse is" << Hyp << ;
To this:
Code:
cout << "The hypoteneuse is" << Hyp;
-
Try this
Code:
int main()
{
int Adj = 10;
float Opp = 12.662;
float Hyp = Opp + Adj;
cout << "The hypoteneuse is" << Hyp <<endl ;
return 0;
}
-
Ah thanks... Omg
I tried using end1 as in endONE, not endL
It looks like a one! lol
And I also tried \n but I don't know why that didn't work...
-
It's an escape sequence. These operate inside strings.
Code:
cout << "new line after this\n" << endl;
cout << "new line after this" << "\n" << endl;
Both produce the same output. The text "new line after this" followed by 2 empty lines (one from "\n" and another from endl.