You are not logged in.

#1 2010-02-07 22:33:16

etereo
Member
Registered: 2009-03-23
Posts: 33

whats wrong with this program?

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

#2 2010-02-07 22:43:29

n0dix
Member
Registered: 2009-09-22
Posts: 956

Re: whats wrong with this program?

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

#3 2010-02-07 22:47:24

jac
Member
From: /home/jac
Registered: 2009-05-19
Posts: 431
Website

Re: whats wrong with this program?

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

#4 2010-02-07 22:52:57

etereo
Member
Registered: 2009-03-23
Posts: 33

Re: whats wrong with this program?

this is C++ sorry i didnt add that

Offline

#5 2010-02-07 22:56:01

etereo
Member
Registered: 2009-03-23
Posts: 33

Re: whats wrong with this program?

cout << "My name is Maria" << endl;

still won't compile, why?

Offline

#6 2010-02-07 22:56:24

n0dix
Member
Registered: 2009-09-22
Posts: 956

Re: whats wrong with this program?

#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

#7 2010-02-07 23:04:29

etereo
Member
Registered: 2009-03-23
Posts: 33

Re: whats wrong with this program?

thank you so much for your time and effort all of you will be blessed for a long time

Offline

#8 2010-02-07 23:06:46

etereo
Member
Registered: 2009-03-23
Posts: 33

Re: whats wrong with this program?

If you could be so kind and answer the second question.

thank you and have a nice day.

Offline

#9 2010-02-07 23:25:59

urist
Member
Registered: 2009-02-22
Posts: 248

Re: whats wrong with this program?

etereo wrote:

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

#10 2010-02-07 23:43:58

etereo
Member
Registered: 2009-03-23
Posts: 33

Re: whats wrong with this program?

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

#11 2010-02-08 19:50:44

PJ
Member
From: Sweden
Registered: 2005-10-11
Posts: 602

Re: whats wrong with this program?

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

#12 2010-02-10 15:28:02

namegame
Member
Registered: 2008-07-29
Posts: 31

Re: whats wrong with this program?

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:

using std::cout;
using std::endl; 
using std::string;

//etc

Offline

#13 2010-02-10 17:35:54

urist
Member
Registered: 2009-02-22
Posts: 248

Re: whats wrong with this program?

namegame wrote:
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

#14 2010-02-11 16:00:38

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: whats wrong with this program?

PJ wrote:

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

Board footer

Powered by FluxBB