1 / 16

Objective:

Objective:. Students will be able to: Create simple C++ programs, compile and run them. Print information from the program. The First Program. #include < iostream > int main (void) { cout << "Hello, world .”; }. Main.

ciara
Download Presentation

Objective:

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Objective: Students will be able to: Create simple C++ programs, compile and run them. Print information from the program

  2. The First Program #include <iostream> int main (void) { cout << "Hello, world.”; }

  3. Main • Indicates the place in the program where the program begins executing. • Keyword • Once the program starts, it executes the program line by line in sequence • The program quits afterthe last line • No limit to the number of statements in main

  4. Cout • This line of code is an output statement • Key word • Special object that allows you to send output to the screen • << Operator that you use with cout and a string to output (print out) the string

  5. ; • All statements in C++ end in a semi-colon ;

  6. {} • C++ uses squiggly braces to group things. • The cout statement is inside the {} of the main • Indentation of the statement visually shows that it is inside the main

  7. Where and how to compile code? We are going to use http://www. codepad.org Steps: • Write your program in a text editor, name and save it. 2. Go to the codepad web site. 3. Click C++ on left hand side of box. 4. Paste code. 5. Check run code if it is not checked 6. Click the submit button

  8. Assignment 1: • 1. Program and successfully run the Hello World program. • 2. Add another line to the program that prints out How are you? After the Hello World line. • To do: Write out the print out!

  9. Assignment 2: • Between the two cout lines add another line: • cout << end1; • Run the program again • To do: Write out the output!

  10. Answer the following question • What does the cout << endl;; do?

  11. Create a program that prints out: Your name Your address Town, State, zip code

  12. Write out the code:

  13. Next assignment: • Create a program that prints out a four word sentence that prints out the code so that one word is on each line. Write out the complete code on the next slide. Example: • The • Program • Is • Cool.

  14. Code for sentence on 4 lines.

  15. Another way to to write the same program in two lines: cout << “The” << end1; <<“program” << end1; cout << “is” <<end1; <<“cool!” << end1;

  16. Hand in packet!!

More Related