New to C++ and Programming, Absolutely new
-
Hello eeryone, I am Mark, am attending Foothill College in SOCAL and I am cmpletely new to all of this. I am having trouble with my first assignment, I will show you. I am on DEV C++ : #include using namespace std; int main() { cout<< "Tran says this is her first computer program."; } { ----------------------------------------- intmain() cout<< "Tran says that."; cout<< "this is her first computer program."; cout<< "Tran says this is her first computer program."; cout<< "Tran says that,"; cout<< "this is her first computer program."; cout<< "Tran said that, "This is my first computer program.""; cout<< "Train said that,."; cout<< ""this is my first computer program.""; cout<< "Tran said that,."; ""this is my first computer program.""; cout<< "Tran said that."; cout<< ""this is my first computer program.""; } This is what My teacher said : Hi Mark, You can only have "int main()" once in your program. Once you put the close curly brace to end it, you can't have any more code below that. If you take another look through the lesson and the textbook reading, you'll see that all of the examples follow that pattern. The solution is to put all of the cout statements inside the first set of curly braces, so you don't need any additional curly braces. Dave Now, I did this here and this is what happened : #include using namespace std; int main() { cout<< "Tran says this is her first computer program."; cout<< "Tran says that."; cout<< "this is her first computer program."; cout<< "Tran says this is her first computer program."; cout<< "Tran says that,"; cout<< "this is her first computer program."; cout<< "Tran said that, "This is my first computer program.""; cout<< "Train said that,."; cout<< ""this is my first computer program.""; cout<< "Tran said that,."; ""this is my first computer program.""; cout<< "Tran said that."; cout<< ""this is my first computer program.""; } This is what my computer said : ( I want to post the Pic, I cannot copy and paste it down.Can somone show me how topost pics on here ? Thanks, If I cannot then I will privately email you. ) So I did what the teacher said to do and then I compile and got more lines all messed up. I am confused... Thanks
-
Hello eeryone, I am Mark, am attending Foothill College in SOCAL and I am cmpletely new to all of this. I am having trouble with my first assignment, I will show you. I am on DEV C++ : #include using namespace std; int main() { cout<< "Tran says this is her first computer program."; } { ----------------------------------------- intmain() cout<< "Tran says that."; cout<< "this is her first computer program."; cout<< "Tran says this is her first computer program."; cout<< "Tran says that,"; cout<< "this is her first computer program."; cout<< "Tran said that, "This is my first computer program.""; cout<< "Train said that,."; cout<< ""this is my first computer program.""; cout<< "Tran said that,."; ""this is my first computer program.""; cout<< "Tran said that."; cout<< ""this is my first computer program.""; } This is what My teacher said : Hi Mark, You can only have "int main()" once in your program. Once you put the close curly brace to end it, you can't have any more code below that. If you take another look through the lesson and the textbook reading, you'll see that all of the examples follow that pattern. The solution is to put all of the cout statements inside the first set of curly braces, so you don't need any additional curly braces. Dave Now, I did this here and this is what happened : #include using namespace std; int main() { cout<< "Tran says this is her first computer program."; cout<< "Tran says that."; cout<< "this is her first computer program."; cout<< "Tran says this is her first computer program."; cout<< "Tran says that,"; cout<< "this is her first computer program."; cout<< "Tran said that, "This is my first computer program.""; cout<< "Train said that,."; cout<< ""this is my first computer program.""; cout<< "Tran said that,."; ""this is my first computer program.""; cout<< "Tran said that."; cout<< ""this is my first computer program.""; } This is what my computer said : ( I want to post the Pic, I cannot copy and paste it down.Can somone show me how topost pics on here ? Thanks, If I cannot then I will privately email you. ) So I did what the teacher said to do and then I compile and got more lines all messed up. I am confused... Thanks
Start simple. First have only one statement within
main()
:#include
using namespace std;int main()
{
cout << "Tran says this is her first computer statement." << endl;
return 0;
}The above is the complete program. No other statements above and below these. Then, upgrade the program to have two statements:
#include
using namespace std;int main()
{
cout << "Tran says this is her first computer statement." << endl;
cout << "Tran says this is her second computer statement." << endl;
return 0;
}And then, go on progressively increasing the complexity. Some compilers need the
return 0
statement since yourmain
is returningint
. -
Start simple. First have only one statement within
main()
:#include
using namespace std;int main()
{
cout << "Tran says this is her first computer statement." << endl;
return 0;
}The above is the complete program. No other statements above and below these. Then, upgrade the program to have two statements:
#include
using namespace std;int main()
{
cout << "Tran says this is her first computer statement." << endl;
cout << "Tran says this is her second computer statement." << endl;
return 0;
}And then, go on progressively increasing the complexity. Some compilers need the
return 0
statement since yourmain
is returningint
.I get it, lets try that. Nope it still wont compile.. Ill keep in touch and sow the tutor tommorow. Thanks
-
I get it, lets try that. Nope it still wont compile.. Ill keep in touch and sow the tutor tommorow. Thanks
Looking at the actual source code in your question you have:
#include
using namespace std;
int main()
...But the
#include
statement is incomplete. You must use that statement to include header files which define the various external classes/methods/functions etc, that you wish to use in your program. So, to use thecout
command, you must include the header that defines the basic I/O stream classes thus:#include
See https://msdn.microsoft.com/en-us/library/zh80x809(v=vs.100).aspx[^] for more details.
-
Hello eeryone, I am Mark, am attending Foothill College in SOCAL and I am cmpletely new to all of this. I am having trouble with my first assignment, I will show you. I am on DEV C++ : #include using namespace std; int main() { cout<< "Tran says this is her first computer program."; } { ----------------------------------------- intmain() cout<< "Tran says that."; cout<< "this is her first computer program."; cout<< "Tran says this is her first computer program."; cout<< "Tran says that,"; cout<< "this is her first computer program."; cout<< "Tran said that, "This is my first computer program.""; cout<< "Train said that,."; cout<< ""this is my first computer program.""; cout<< "Tran said that,."; ""this is my first computer program.""; cout<< "Tran said that."; cout<< ""this is my first computer program.""; } This is what My teacher said : Hi Mark, You can only have "int main()" once in your program. Once you put the close curly brace to end it, you can't have any more code below that. If you take another look through the lesson and the textbook reading, you'll see that all of the examples follow that pattern. The solution is to put all of the cout statements inside the first set of curly braces, so you don't need any additional curly braces. Dave Now, I did this here and this is what happened : #include using namespace std; int main() { cout<< "Tran says this is her first computer program."; cout<< "Tran says that."; cout<< "this is her first computer program."; cout<< "Tran says this is her first computer program."; cout<< "Tran says that,"; cout<< "this is her first computer program."; cout<< "Tran said that, "This is my first computer program.""; cout<< "Train said that,."; cout<< ""this is my first computer program.""; cout<< "Tran said that,."; ""this is my first computer program.""; cout<< "Tran said that."; cout<< ""this is my first computer program.""; } This is what my computer said : ( I want to post the Pic, I cannot copy and paste it down.Can somone show me how topost pics on here ? Thanks, If I cannot then I will privately email you. ) So I did what the teacher said to do and then I compile and got more lines all messed up. I am confused... Thanks