Output

1,525 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,525
On SlideShare
0
From Embeds
0
Number of Embeds
1,255
Actions
Shares
0
Downloads
5
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Output

  1. 1. CS111 Lab Basics, Output, and Comments Instructor: Michael Gordon
  2. 2. C++ Basics  Every program you write in this class will contain these two first lines:  #include <iostream>  using namespace std;  And each “main” program will begin:  int main(){  And end with:  return 0; }
  3. 3. C++ Basics  The body of the main program will be contained between { and return 0; }.  Code written between these (and any) brackets should be indented.  Every instruction you give in C++ must end with a semicolon - ;
  4. 4. Input and Output  To output text, numbers, or (later) variable values, we use: cout<<  Output is said to be displayed to the Console.  The reverse operation (input) is: cin>>  Input is received from the Console.  We will discuss cin more later.
  5. 5. Outputting Text  Any text that you want to output must be written in quotes: “Hello world.”  Multiple sets of text must include << between them.  Ex: cout<<“Hello “<<“Michael!”;  Remember to include spaces!  Use <<endl for a new line character.
  6. 6. Comments  Comments are ignored by the compiler. They are meant only for other programmers (or yourself) reviewing your code.  Comments can do the following:  Explain what part of the program does  Provide information on the author  Serve as a note to the programmer while the program is in progress of what is left to do.
  7. 7. Comments  Using // will cause the compiler to ignore the rest of the line. Ex: //This is my comment  Or comment multiple lines like so: /* Comment line 1 Comment line 2 Comment line 3 */

×