Anyone know about c++?
This is a program with some errors in it to be corrected int main; { integer a floating_point b character c Cout < a < b < c return 0 }
dont you need a Cin ?
why?
what is the program supposed to do
nothing, it's just an assignment to correct the syntax errors
oh ok :)
do you have an online book or website i could check
umm no just textbook
whats the textbook called?
well it's not a problem from the textbook
ok, im just wondering the name of the textbook, can you recommend me one. im interested in learning c++
i think Cout is written " cout >> "
starting out with c++ 7th edition
yeah that's what i thought
oh ok :)
well, first of all, add a semi colon after each line within the braces
replace the ; after main with ()
this is what i got so far int main() { integer = a; floating_point = b; character = c; Cout << a << b << c return 0 }
int main() { int a; float b; char c; cout << a << b << c; return 0; }
thx
cout uses <<
cin uses >>
kk
would this compile?
why don't you try and see? I have a feeling it won't, but I don't really remember C++ that well.
would probly have to add #include <iostream> using namespace std;
shouldn't i use = to assign a b c to float int and char ?
no.
k
thx for the help ppl
int a = 1 float b = 2 char c ='x'
Without initializing the variables you can still print the variables but you will get whatever is in memory at that location which could be gibberish.
Oh, ok, thought it would give an error.. Haven't looked at cpp in a while.
Also semi-colons at the end of each initialization above.
okay i'm wondering don't i need to say #include <iostream> in order to use cout?
Yes. Also, the float b = 2 should be changed to float b = 2.1 (a decimal number or else some compiler will complain).
kk
hahah yea, im starting to forget about semicolons.. Love python.. all you gotta do is: def main(): print a, b, c
or in python 3: def main(): print(a, b, c)
okay this is what i have so far dya think it'l compile? #include <iostream> int main() { int a = 1; float b = 2.1; char c = 'x'; cout << a << b << c; return 0; }
using namespace std;
#include <iostream> using namespace std; int main() { int a = 1; float b = 2.1; char c = 'x'; cout << a << b << c; return 0; }
there
Should compile. But you can always try it and modify it if it complains.
thx so much
yw.
Join our real-time social learning platform and learn together with your friends!