You are not logged in.
Pages: 1
Topic closed
What, if anything, is wrong with the following cout statement?
cout >> "My name is Maria; << endl
What, if anything, is wrong with the following program?
#include <iosteam main(){ cout << "Is there something
wrong " << endl << endl cout << "with this program"?; }
thank you and god bless
Offline
I have a question, @etereo, is this a new C++ code? I think you missed very things in that code. What about a hello world in C++?
Offline
More specifically, in the first you don't end the quote so the entire line is still trying to be outputted. Also, both of those "<<"/">>" should just be "<<". You probably want it to look like:
cout << "My name is Maria" << endl;
I suggest you look for some tutorials. You can find loads on google, or whatever search engine you prefer.
Offline
this is C++ sorry i didnt add that
Offline
cout << "My name is Maria" << endl;
still won't compile, why?
Offline
#include <iostream>
using namespace std;
int main(){
cout << "Hello World!" << endl;
cout << "Welcome to C++ Programming" << endl;
return 0;
}
Last edited by n0dix (2010-02-07 22:58:00)
Offline
thank you so much for your time and effort all of you will be blessed for a long time
Offline
If you could be so kind and answer the second question.
thank you and have a nice day.
Offline
What, if anything, is wrong with the following program?
#include <iosteam main(){ cout << "Is there something wrong " << endl << endl cout << "with this program"?; }
thank you and god bless
There's no need to separate the cout statements like that:
#include <iostream>
using namespace std;
int main(){
cout << "Is there something wrong" << endl << endl << "with this program?";
return 0;
}
or replace the one cout statement above with these two:
cout << "Is there something wrong" << endl << endl;
cout << "with this program?";
You also can't use cout by itself with just #include <iostream>. If you want to use cout without using namespace std;, you have to use std::cout.
Last edited by urist (2010-02-07 23:26:26)
Offline
thanks for all the great help on the forum i have learned a lot the <iosteam> was a typo error i meant to put <iostream>
Offline
Well, I think your examples in your first post looks to much like homework. If it was homework, I think you should try to learn it yourself and not ask for a complete solution. If you don't understand the basic stuff you will have problems later with more advanced programming.
Offline
You also can't use cout by itself with just #include <iostream>. If you want to use cout without using namespace std;, you have to use std::cout.
You can also do the following:
using std::cout;
using std::endl;
using std::string;
//etc
Offline
urist wrote:You also can't use cout by itself with just #include <iostream>. If you want to use cout without using namespace std;, you have to use std::cout.
You can also do the following:
stuff
Just thought I'd simplify it a bit.
Offline
Well, I think your examples in your first post looks to much like homework. If it was homework, I think you should try to learn it yourself and not ask for a complete solution. If you don't understand the basic stuff you will have problems later with more advanced programming.
this.
Closing. You've already gotten way more help than you should have.
Offline
Pages: 1
Topic closed