SlideShare a Scribd company logo
1 of 7
Download to read offline
CS111 Lab
Basics, Output, and
Comments
Instructor: Michael Gordon
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;
}
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 - ;
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.
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.
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.
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
*/

More Related Content

What's hot

Assignement of programming & problem solving(3)a.z
Assignement of programming & problem solving(3)a.zAssignement of programming & problem solving(3)a.z
Assignement of programming & problem solving(3)a.z
Syed Umair
 
05 control structures 2
05 control structures 205 control structures 2
05 control structures 2
Jomel Penalba
 
Assignement of programming & problem solving ass.(3)
Assignement of programming & problem solving ass.(3)Assignement of programming & problem solving ass.(3)
Assignement of programming & problem solving ass.(3)
Syed Umair
 

What's hot (20)

My first program in c, hello world !
My first program in c, hello world !My first program in c, hello world !
My first program in c, hello world !
 
c++ programming Unit 2 basic structure of a c++ program
c++ programming Unit 2 basic structure of a c++ programc++ programming Unit 2 basic structure of a c++ program
c++ programming Unit 2 basic structure of a c++ program
 
Writing first C Program
Writing first C ProgramWriting first C Program
Writing first C Program
 
C programming on Ubuntu
C programming on UbuntuC programming on Ubuntu
C programming on Ubuntu
 
Learning c programming by rbm
Learning c programming by rbmLearning c programming by rbm
Learning c programming by rbm
 
Fp201 unit2 1
Fp201 unit2 1Fp201 unit2 1
Fp201 unit2 1
 
OOPS using C++
OOPS using C++OOPS using C++
OOPS using C++
 
C program to write c program without using main function
C program to write c program without using main functionC program to write c program without using main function
C program to write c program without using main function
 
Experiment 9(exceptions)
Experiment 9(exceptions)Experiment 9(exceptions)
Experiment 9(exceptions)
 
C Programming- Harsh Sharma
C Programming- Harsh SharmaC Programming- Harsh Sharma
C Programming- Harsh Sharma
 
Lecture 3 c++
Lecture 3 c++Lecture 3 c++
Lecture 3 c++
 
#Include
#Include#Include
#Include
 
C++ chapter # 1
C++ chapter # 1C++ chapter # 1
C++ chapter # 1
 
C++ Chapter 3
C++ Chapter 3C++ Chapter 3
C++ Chapter 3
 
Assignement of programming & problem solving(3)a.z
Assignement of programming & problem solving(3)a.zAssignement of programming & problem solving(3)a.z
Assignement of programming & problem solving(3)a.z
 
05 control structures 2
05 control structures 205 control structures 2
05 control structures 2
 
Intro To C++ - Class 03 - An Introduction To C++ Programming, Part II
Intro To C++ - Class 03 - An Introduction To C++ Programming, Part IIIntro To C++ - Class 03 - An Introduction To C++ Programming, Part II
Intro To C++ - Class 03 - An Introduction To C++ Programming, Part II
 
Assignement of programming & problem solving ass.(3)
Assignement of programming & problem solving ass.(3)Assignement of programming & problem solving ass.(3)
Assignement of programming & problem solving ass.(3)
 
Basic of c programming www.eakanchha.com
Basic of c programming www.eakanchha.comBasic of c programming www.eakanchha.com
Basic of c programming www.eakanchha.com
 
Programs that work in c and not in c
Programs that work in c and not in cPrograms that work in c and not in c
Programs that work in c and not in c
 

Viewers also liked

Introduction to Linux, Pico, G++
Introduction to Linux, Pico, G++Introduction to Linux, Pico, G++
Introduction to Linux, Pico, G++
Michael Gordon
 

Viewers also liked (14)

Shape logic 1
Shape logic 1Shape logic 1
Shape logic 1
 
Sage crm introduction by Triad Software
Sage crm introduction by Triad SoftwareSage crm introduction by Triad Software
Sage crm introduction by Triad Software
 
If statements
If statementsIf statements
If statements
 
Functions
FunctionsFunctions
Functions
 
Scope of variables
Scope of variablesScope of variables
Scope of variables
 
Writing edit free billing entries2 (3) (2)
Writing edit free billing entries2 (3) (2)Writing edit free billing entries2 (3) (2)
Writing edit free billing entries2 (3) (2)
 
Introduction to Linux, Pico, G++
Introduction to Linux, Pico, G++Introduction to Linux, Pico, G++
Introduction to Linux, Pico, G++
 
While loops
While loopsWhile loops
While loops
 
貧窮
貧窮貧窮
貧窮
 
Input and output in C++
Input and output in C++Input and output in C++
Input and output in C++
 
Splout SQL - Web latency SQL views for Hadoop
Splout SQL - Web latency SQL views for HadoopSplout SQL - Web latency SQL views for Hadoop
Splout SQL - Web latency SQL views for Hadoop
 
AVR_Course_Day3 c programming
AVR_Course_Day3 c programmingAVR_Course_Day3 c programming
AVR_Course_Day3 c programming
 
Constructors & destructors
Constructors & destructorsConstructors & destructors
Constructors & destructors
 
Computer science project work
Computer science project workComputer science project work
Computer science project work
 

Similar to Output

Similar to Output (20)

Beginner C++ easy slide and simple definition with questions
Beginner C++ easy slide and simple definition with questions Beginner C++ easy slide and simple definition with questions
Beginner C++ easy slide and simple definition with questions
 
Basics Of C++.pptx
Basics Of C++.pptxBasics Of C++.pptx
Basics Of C++.pptx
 
Intro To C++ - Class 3 - Sample Program
Intro To C++ - Class 3 - Sample ProgramIntro To C++ - Class 3 - Sample Program
Intro To C++ - Class 3 - Sample Program
 
IITK ESC 111M Lec02.pptx .
IITK ESC 111M Lec02.pptx               .IITK ESC 111M Lec02.pptx               .
IITK ESC 111M Lec02.pptx .
 
C++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWAREC++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWARE
 
Practical basics on c++
Practical basics on c++Practical basics on c++
Practical basics on c++
 
Lab 1.pptx
Lab 1.pptxLab 1.pptx
Lab 1.pptx
 
Introduction to C++,Computer Science
Introduction to C++,Computer ScienceIntroduction to C++,Computer Science
Introduction to C++,Computer Science
 
C# 6Write a program that creates a Calculation ClassUse the foll.pdf
C# 6Write a program that creates a Calculation ClassUse the foll.pdfC# 6Write a program that creates a Calculation ClassUse the foll.pdf
C# 6Write a program that creates a Calculation ClassUse the foll.pdf
 
Introduction to cpp
Introduction to cppIntroduction to cpp
Introduction to cpp
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
C introduction
C introductionC introduction
C introduction
 
Introduction to cpp language and all the required information relating to it
Introduction to cpp language and all the required information relating to itIntroduction to cpp language and all the required information relating to it
Introduction to cpp language and all the required information relating to it
 
C++basics
C++basicsC++basics
C++basics
 
C Introduction and bascis of high level programming
C Introduction and bascis of high level programmingC Introduction and bascis of high level programming
C Introduction and bascis of high level programming
 
Cordovilla
CordovillaCordovilla
Cordovilla
 
Unit 1 of c++ first program
Unit 1 of c++ first programUnit 1 of c++ first program
Unit 1 of c++ first program
 
C introduction
C introductionC introduction
C introduction
 
Basic c programming and explanation PPT1
Basic c programming and explanation PPT1Basic c programming and explanation PPT1
Basic c programming and explanation PPT1
 
First Class
First ClassFirst Class
First Class
 

More from Michael Gordon (12)

Raspberry Pi presentation for Computer Architecture class
Raspberry Pi presentation for Computer Architecture classRaspberry Pi presentation for Computer Architecture class
Raspberry Pi presentation for Computer Architecture class
 
Strings2
Strings2Strings2
Strings2
 
Strings1
Strings1Strings1
Strings1
 
Introduction to Computer Science 111 Lab
Introduction to Computer Science 111 LabIntroduction to Computer Science 111 Lab
Introduction to Computer Science 111 Lab
 
Strings
StringsStrings
Strings
 
Arrays, continued
Arrays, continuedArrays, continued
Arrays, continued
 
Arrays
ArraysArrays
Arrays
 
For loops
For loopsFor loops
For loops
 
Arithmetic
ArithmeticArithmetic
Arithmetic
 
Variables
VariablesVariables
Variables
 
Word cloud
Word cloudWord cloud
Word cloud
 
Millennial white paper
Millennial white paperMillennial white paper
Millennial white paper
 

Recently uploaded

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 

Output

  • 1. CS111 Lab Basics, Output, and Comments Instructor: Michael Gordon
  • 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. 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. 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. 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. 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. 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 */