Sign In | Subscribe
Start learning today, and be successful in your academic & professional career. Start Today!
Loading video...
This is a quick preview of the lesson. For full access, please Log In or Sign up.
For more information, please see full course syllabus of Introduction to C++
  • Discussion

  • Study Guides

  • Download Lecture Slides

  • Table of Contents

  • Related Services

Bookmark and Share
Lecture Comments (90)

1 answer

Last reply by: Alvin Sylvain
Sat Sep 26, 2015 5:03 PM

Post by Soumyanil Banerjee on April 19, 2015

Where can we get solution to the homeworks?

0 answers

Post by Emily Lewis on January 17, 2015

I am also having trouble with installing Eclipse. Can you give me specific instructions on how to do this?

1 answer

Last reply by: Salman Khan
Tue Oct 6, 2015 2:08 PM

Post by Emily Lewis on January 17, 2015

I am using the latest versions of MinGW and Programmer's Notepad editor, and when I try to run the command when testing it, it doesn't work. How do you run the command?

3 answers

Last reply by: Matthew Bowman84
Fri Nov 28, 2014 7:16 PM

Post by Matthew Bowman84 on November 26, 2014

I originally had char middle [1] and cin.getline(middle, 1)
The program didn't work correctly until I changed it to 20, why is that?
I was only using one character for the middle initial.


#include <iostream>
using namespace std;

int main() {
   cout << "What is your first name? ";
   char first[20];
   cin.getline(first, 20);
   cout << "What is your middle initial? ";
   char middle[20];
   cin.getline(middle, 20);
   cout << "What is your last name? ";
   char last[20];
   cin.getline(last, 20);
   cout << "Your name is: " << last << ", " << first << " " << middle << endl;
}

4 answers

Last reply by: Alvin Sylvain
Thu Nov 27, 2014 12:16 AM

Post by ido montia on November 14, 2014

about Q3

is that ok Prof Sylvain ?

#include <iostream>
using namespace std;

int main() {
cout << "What's your heights in feet? ";
int feet;
int inches;
cin >> feet;
inches = feet * 5;
cout << "OK! SO That's Your Height in inches =>" << inches << endl;
cin.get();
cin.get();


}

1 answer

Last reply by: Alvin Sylvain
Sat Oct 4, 2014 3:43 PM

Post by john felletter on October 4, 2014

Hi Prof Sylvain:
I was able to run the programs on my first run through. When I tried to do the homework, I started receiving the error ( referring to the line where I had input #includes <iostream>), "Fatal error: iostream: No such file or directory. Now I am getting that message on all of my programs, even the ones that worked yesterday.

Thank you.
John

2 answers

Last reply by: Jimmy Wan
Sat Oct 4, 2014 8:55 PM

Post by Jimmy Wan on September 30, 2014

I've tried "Hello World" numerous times however all I get is "press any ky to continue" I have an assignment due in 2 days and I am really stressing out because I cannot do something simple like this.

1 answer

Last reply by: Dan Zhang
Sun Jul 13, 2014 11:43 AM

Post by Fawzy Hegab on July 10, 2014

I use dev-c++ as a compiler . when I copied the code of first program. it didn't work! it says that source code doesn't exist ! I have saved the file with extension cpp. What to do ?? I have tried to download cbt and downloaded a file from the site 73 mega and discovered it's not the compiler ... can you give me the link to it here please ?

I have also downloaded mingw . it took time to download packs but I don't know where to find the compiler ! it doesn't exist in all programms . what exists is minGW installation manger ...

and advice ?

4 answers

Last reply by: Alvin Sylvain
Sat May 31, 2014 1:37 AM

Post by Jodi Goll on May 26, 2014

When writing the second program, I typed out the entire thing exactly as it is shown in the video.
On this line though:
<< " in dog years!" << endl;
I'm getting flagged for a syntactical error as soon as I type the initial <<
What should I do to fix this?

1 answer

Last reply by: Alvin Sylvain
Wed Apr 9, 2014 3:27 PM

Post by Farhat Muruwat on April 9, 2014

On the HW what am I doing Wrong. Here is the code. It says height is not declared but I told program it is an integer.

int main() {
cout << "What is your height in feet?"; // ask for height

int height;

cin >> height;

int inches = height * 12;

cout << "You are " << inches
    << " inches" << endl;

}

2 answers

Last reply by: Farhat Muruwat
Wed Apr 9, 2014 10:33 PM

Post by Farhat Muruwat on April 4, 2014

Eclipse is NOT easy to use. It took me 2 days to get it link to CYGIN. Now I am on it and it is challenge to simply start new projects.

1 answer

Last reply by: Alvin Sylvain
Thu Apr 3, 2014 2:04 PM

Post by Thuy Nguyen on April 3, 2014

In Eclipse the cin.getLine(name, 20), could not be resolved.  What is wrong?

1 answer

Last reply by: Alvin Sylvain
Thu Apr 3, 2014 2:07 PM

Post by Thuy Nguyen on April 3, 2014

The small font is not easy for me to see.  "Not having time to make the font bigger" is irresponsible, the font should have been adjusted beforehands.  

1 answer

Last reply by: Alvin Sylvain
Mon Mar 24, 2014 3:55 PM

Post by DASOL KWON on March 24, 2014

How can I check the answers for the homework? And, can I use the visual studio? I am kind of confusing to start it...help me

1 answer

Last reply by: Alvin Sylvain
Wed Dec 4, 2013 12:01 PM

Post by Adulaziz Al-etaibi on December 4, 2013

#include <iostream>
using namespace std;
     int main ()
     {
         
         cout << "what's your weight  in pounds ? " << endl;
         double weight  ;
         cin >> weight  ;
        double whight_in_stone = 0.0714 * whight;
        cout << "your whight in stone is " << whight_in_stone << endl;
        return 0
       
       
can somebody tell me why it doesn't work ?

0 answers

Post by Adulaziz Al-etaibi on December 3, 2013

sorry the answers in the link are wrong apologize

0 answers

Post by Adulaziz Al-etaibi on December 3, 2013

http://www.cplusplus.com/forum/beginner/102373/ here's a link for the homework answers

1 answer

Last reply by: Alvin Sylvain
Wed Dec 4, 2013 12:04 PM

Post by Adulaziz Al-etaibi on December 3, 2013

can somebody post the homework answers ?

1 answer

Last reply by: Alvin Sylvain
Wed Dec 4, 2013 12:06 PM

Post by Adulaziz Al-etaibi on December 3, 2013

tip: you might add  cin.get (); or system ("pause"); to your code to pause the screen

1 answer

Last reply by: Alvin Sylvain
Sun Sep 8, 2013 5:12 PM

Post by G Johnson on September 8, 2013

I sent you a question on Sept 7 and I forgot to mention that Im using Microsoft Visual Studio Express 2012. Would that be the reason i was having the precompiled error i mentioned on Sept 7?

1 answer

Last reply by: Alvin Sylvain
Sat Sep 7, 2013 6:02 PM

Post by G Johnson on September 7, 2013

When I try to build the program, its giving me an error message that says: unexpected end of file while looking for precompiled header.Did you forget to add #include stdafx.h to your source?

1 answer

Last reply by: Alvin Sylvain
Thu Sep 5, 2013 7:40 AM

Post by G Johnson on September 4, 2013

Hello, when I try to compile my hello world program, it tells me that cout and endl are undefined. Do I have to create a header named iostream? my header file is stdio.h.

1 answer

Last reply by: Alvin Sylvain
Tue May 28, 2013 6:23 PM

Post by G Johnson on May 27, 2013

hello. im having trouble compiling and running my hello world program. Im using Visual C++ Express 2010.

0 answers

Post by Barbara Corrison on March 20, 2013

When I get about 15 minutes in the video jumps straight back to the beginning! I've set the Flash settings to maximum storage. Please help.
Thanks

1 answer

Last reply by: Alvin Sylvain
Sat Mar 9, 2013 7:13 PM

Post by Andrew Yang on March 9, 2013

How would you set up this on visual studio?

3 answers

Last reply by: Alvin Sylvain
Fri Dec 21, 2012 11:04 PM

Post by Natalia Alvarez on December 19, 2012

Hi I installed Eclipse and MinGW. The PATH is OK.
I know that because I wrote the following file:
#include <iostream>
int main()
{
std::cout << "Hello Natalia!
";
return 0;
}
I called hello.cpp, then from the cmd (windows 7 64-bit)
I ran:
c:\test\g++ hello.cpp -o hello.exe
and got hello.exe compiled correctly
when I run it in the command prompt it executes properly.
so, basically there is no problems with the path to g++,
However, Eclipse keep throwing the following errors:
"Program "g++" not found in PATH
and
"Program "gcc" not found in PATH
I already opened the "Windows/Preferences/C/C++/Build and pressed
restore preferences, but the same happens.
Any idea on what is going on?

1 answer

Last reply by: Alvin Sylvain
Tue Nov 20, 2012 7:28 PM

Post by Christopher Cruise on November 19, 2012

Hi. Can you go into more detail on what the std and std:: does? Thank you!

0 answers

Post by Christopher Cruise on November 13, 2012

Well I was trying to understand what the #include <iostream> does; i've always had trouble with that. I'll watch the rest of your videos though, I'm sure you'll get into it. I would assume I have to add the #include <iosteam> on the next line after #include "billy" ? I'll keep watching, thanks for your time!

1 answer

Last reply by: Alvin Sylvain
Mon Nov 12, 2012 9:32 PM

Post by Christopher Cruise on November 12, 2012

Hello, when I tried it it said there was a problem. Here's my code, maybe I did it wrong? The wrong usage of it -- this is just what I did on my understanding of what you said.

#include "billy"
using namespace std;
int main() {
cout <<"hello world text" <<endl;
system("PAUSE");
return 0;
}

and then I guess if I understand correctly -- which I know you said not to look at it as linking, but I would 'link' billy2 to this page which has my other half of text. Is this the right way?

1 answer

Last reply by: Alvin Sylvain
Thu Nov 8, 2012 7:49 PM

Post by Christopher Cruise on November 8, 2012

Hi, what do you mean by 'the pre-processor will "copy" the entire contents of the file "part2" then "paste" it in place of the "#include" line.'? I understood your first comment but got confused by the second. :/

2 answers

Last reply by: Charlie Jiang
Thu Aug 8, 2013 7:04 PM

Post by Christopher Cruise on November 7, 2012

Hi. That helps very much! Thank you. Just so I understand,
my code can be:
#include "part2"
cout << "This is it" <<endl;
return 0;

is the #include iostream or in my example '"part2"'
like a link rel? linking one page to another?

2 answers

Last reply by: Christopher Cruise
Wed Nov 7, 2012 2:13 PM

Post by Christopher Cruise on November 5, 2012

Hi, can you go into a little more detail about what the #include <iostream> does?
Thanks...

0 answers

Post by jacob johnson on November 4, 2012

For anyone using Visual Studio, adding system("pause"); to the end of the main function will stop the console window from closing automatically. It looks like there is also a setting you can change in the project, but couldn't find instructions for VS 2012.

0 answers

Post by David McNeill on September 26, 2012

If you are having a problem getting your eclipse and MinGW setup go to this youtube video it will explain it very clearly. It got me working.
http://www.youtube.com/watch?v=rgt3PJ5DvH4&list=PL3345A50B73C26A6F&index=1&feature=plpp_video

0 answers

Post by Gwendolyn Cummings on September 1, 2012

Hi Gwendolyn, sorry to hear you're having difficulties.

Which compiler are you using? From the look of your error messages, it appears that whatever compiler you have was not properly installed.

If you're using MinGW, make sure to set up the PATH environment variable to point to both the MinGW compiler and the MinGW System environment. That would include both MinGW\bin and MinGW\msys\1.0\bin.

1 answer

Last reply by: Alvin Sylvain
Sun Sep 16, 2012 10:28 PM

Post by austin schneit on August 10, 2012

Hi Professor,

Just a note about the website to download the MinGW software. The website is mingw.org and not mingw.com.

Thanks

3 answers

Last reply by: Alvin Sylvain
Thu Aug 2, 2012 3:25 PM

Post by Alex Abraham on July 25, 2012

Hey guys i have a question for anyone that might be able to help me out

ON HOMEWORK PROBLEM #6

I was able to get it working but if i try to change the limit of characters for Middle Initial to 1, it asks for first name, asks for middle initial, and then skips over asking last name and just prints out first name :(

HERE IS THE SOURCE CODE IF ANYONE WANTS TO TAKE A LOOK


//============================================================================
// Name : HW.cpp
// Author : Alex Abraham
// Version : 1.0
// Copyright : 2012
// Description : Homework for Getting Started in C++ Course
//============================================================================

#include <iostream>
using namespace std;

int main() {

//This program will ask for your name and then print it back to you.
//Ask for first name
cout << "What is your first name?" << endl;
char first [20];
cin.getline(first, 20);
//Ask for middle name
cout << "What is your middle initial?" << endl;
char middle [1];
cin.getline(middle, 1);
//Ask for last name
cout << "What is your last name?" << endl;
char last [20];
cin.getline(last, 20);
//Print name in order [Last, First Middle]
cout << "Hello " << last << ", " << first << " " << middle << endl;

return 0;
}

0 answers

Post by Alex Abraham on July 25, 2012

Hey guys i have a 64 bit windows system and i was having trouble with getting the c++ compiler to play nice with the 64 bit version of eclipse. I did some research online and found out that this was a known bug for the 64 bit version of eclipse and that a workaround is to simply download the 32 bit version. I suggest trying it out if anyone has problems with running programs in eclipse

0 answers

Post by julius mogyorossy on July 23, 2012

I too am very grateful for this C++ course, thanks, it is a dream come true. I have that happen a lot, dreams coming true, but not enough, ie, always, some day. Educator you might appreciate something I said on my blog, I said that if I had children I would come to Educator.com to learn math if only so that I could help my children with their math homework.

0 answers

Post by Chudamuni Dahal on June 12, 2012

Guys if Eclipse is not working, use this: http://sourceforge.net/projects/codeblocks/files/Binaries/10.05/Windows/codeblocks-10.05mingw-setup.exe/download this is code block compiler! It's awesome and my favorite c compiler.

0 answers

Post by John Haynes on June 9, 2012

I cannot figure out how to edit the hello world code in order to make sure I have properly set up MinGW. I am trying to use eclipse but I am unaware of how I am supposed to use this

0 answers

Post by kristof anderson on June 9, 2012

If you are on Ubuntu or other Linux systems an easier IDE to use is Geany that's my preffered one if you do not like the one offered.

0 answers

Post by Ashraf Saeed on June 3, 2012

plus when I run it, it gives two options. 1) ant build and 2) ant build...

0 answers

Post by Ashraf Saeed on June 3, 2012

Mr.Sylvain I am having a problem and I can't figure it out. When I open the helloworld.cpp file from the archive file in eclipse. It is not allowing me build it and does not allow me to run it either. Could you please help me?

Getting Started

Getting Started

Lecture Slides are screen-captured images of important points in the lecture. Students can download and print out these lecture slide images to do practice problems as well as take notes while watching the lecture.

  • Intro 0:00
  • Overview 0:15
  • Acquiring a C++ Compiler - Windows 1:06
  • Setting up MinGW 2:44
  • Acquiring a C++ Compiler - Others 3:24
    • Redhat (Fedora) Linux
    • Ubuntu (Debian) Linux
    • Apple Macintosh
  • Acquiring a C++ Compiler - IDE 5:05
    • Eclipse CDT
    • Eclipse Older Version
  • Acquiring an Editor 6:46
  • Acquiring an Editor 8:36
    • Linux
    • Macintosh
  • 'Hello World' Everybody's First Program 9:35
    • Source Code
  • Basic Program Structure 17:50
    • Example
  • Basic Program Structure 21:02
    • Main Function Definition
  • Compiling, Linking, Running 22:14
    • Examples: Compile
    • Link
  • Build Tools 26:11
    • Build a 'Makefile'
    • Integrated Development Environment (IDE)
  • Quick Note on Variable Declaration 28:03
    • Example: Integers
    • Example: Floating Point Numbers
  • Your Second Program - User Input Basic 'How Old Are You?' 30:49
  • Workspace / Source Code 32:21
    • New Workspace
  • Quick Note on Character Arrays 34:44
    • Example
  • Your Third Program - User Text Input 'What’s Your Name?' 37:13
    • Example
    • Workspace
  • Do Your Homework! 42:56