Ask your own question, for FREE!
Mathematics 10 Online
OpenStudy (anonymous):

Anyone know about c++?

OpenStudy (anonymous):

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 }

OpenStudy (perl):

dont you need a Cin ?

OpenStudy (anonymous):

why?

OpenStudy (perl):

what is the program supposed to do

OpenStudy (anonymous):

nothing, it's just an assignment to correct the syntax errors

OpenStudy (perl):

oh ok :)

OpenStudy (perl):

do you have an online book or website i could check

OpenStudy (anonymous):

umm no just textbook

OpenStudy (perl):

whats the textbook called?

OpenStudy (anonymous):

well it's not a problem from the textbook

OpenStudy (perl):

ok, im just wondering the name of the textbook, can you recommend me one. im interested in learning c++

OpenStudy (perl):

i think Cout is written " cout >> "

OpenStudy (anonymous):

starting out with c++ 7th edition

OpenStudy (anonymous):

yeah that's what i thought

OpenStudy (perl):

oh ok :)

OpenStudy (agent47):

well, first of all, add a semi colon after each line within the braces

OpenStudy (agent47):

replace the ; after main with ()

OpenStudy (anonymous):

this is what i got so far int main() { integer = a; floating_point = b; character = c; Cout << a << b << c return 0 }

OpenStudy (agent47):

int main() { int a; float b; char c; cout << a << b << c; return 0; }

OpenStudy (anonymous):

thx

OpenStudy (agent47):

cout uses <<

OpenStudy (agent47):

cin uses >>

OpenStudy (anonymous):

kk

OpenStudy (anonymous):

would this compile?

OpenStudy (agent47):

why don't you try and see? I have a feeling it won't, but I don't really remember C++ that well.

OpenStudy (anonymous):

would probly have to add #include <iostream> using namespace std;

OpenStudy (anonymous):

shouldn't i use = to assign a b c to float int and char ?

OpenStudy (ranga):

no.

OpenStudy (anonymous):

k

OpenStudy (anonymous):

thx for the help ppl

OpenStudy (agent47):

int a = 1 float b = 2 char c ='x'

OpenStudy (ranga):

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.

OpenStudy (agent47):

Oh, ok, thought it would give an error.. Haven't looked at cpp in a while.

OpenStudy (ranga):

Also semi-colons at the end of each initialization above.

OpenStudy (anonymous):

okay i'm wondering don't i need to say #include <iostream> in order to use cout?

OpenStudy (ranga):

Yes. Also, the float b = 2 should be changed to float b = 2.1 (a decimal number or else some compiler will complain).

OpenStudy (anonymous):

kk

OpenStudy (agent47):

hahah yea, im starting to forget about semicolons.. Love python.. all you gotta do is: def main(): print a, b, c

OpenStudy (agent47):

or in python 3: def main(): print(a, b, c)

OpenStudy (anonymous):

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; }

OpenStudy (agent47):

using namespace std;

OpenStudy (anonymous):

#include <iostream> using namespace std; int main() { int a = 1; float b = 2.1; char c = 'x'; cout << a << b << c; return 0; }

OpenStudy (anonymous):

there

OpenStudy (ranga):

Should compile. But you can always try it and modify it if it complains.

OpenStudy (anonymous):

thx so much

OpenStudy (ranga):

yw.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!