SlideShare a Scribd company logo
Lesson 2 starting output
Remember these they work in our editor
Operation Key Combo
Cut ctrl + x
Copy ctrl + c
Paste ctrl + v
Save ctrl + s
Undo ctrl + z
//first program – this is a comment
#include <iostream>
int main()
{
return 0;
}
basic application review
Some languages provide keywords to perform specific tasks
for, class, int
C++ uses functions and classes for just about everything
A library called The Standard Library comes with your tools
And the tools know where to find it
Libraries
#include<iostream>
this includes a library that allows us to use the
We use libraries all the time in programming
You will be using many at times
Operands
insertion >> and extraction << operators
cout << and cin >>
std:: cout << //allows data to be read from the stream
std::cin >> //allows data to be sent to the stream
endl is the end line command (like hitting the enter key)
We can use using namespace std; at the top of a program
This allows us not to type std:: before every cout << or cin >> statement.
cout <<
Output stream – anything following can be output to the screen
Text is enclosed in “ “ and is considered a literal. Numbers are
considered literals and print as they are.
Expressions are evaluated and the result printed.
cout << “hello”; displays the word hello to the screen.
cout << 2; displays the number 2 cout << “2”; will work too.
cout << 2 + 2; displays 4
cout << “2 + 2”; displays 2 + 2
cout << endl; drops to next line
cout << “” is an escape sequence. The compiler is looking for another character to do something at that
point. Sometimes you need to print a “” or a “ but they are part of the syntax so this allows you a way.
Example cout << “hellonworld”; displays:
hello
world
The n is for new line
Others include
Escape sequence character represented
a Alarm (Beep, Bell)
b Backspace
f Formfeed
n Newline (Line Feed)
r Carriage Return
t Horizontal Tab
v Vertical Tab
 Backslash
' Single quotation mark
" Double quotation mark
? Question mark
Issues
endl needs to be it’s own statement ex. Can’t be cout << “Hello” cout << endl;
has to be cout << “Hello”; cout <<endl;
or cout << “Hello”;
cout << endl;
Can be cascaded on the same cout without the semi colon - Best Way!
ex. cout << “Hello” << endl; //makes it easier to follow as a programmer
C++ runs in sequence so we need the libraries set as below – Top – Down Design
#include <iostream>
using namespace std;
Notice the formatting – white space / indenting and next lines
// this will run just fine but would be a nightmare to code and read
#include <iostream> int main(){return 0;}
//this is what we need
#include <iostream>
int main()
{
return 0;
}
Don’t ask for the impossible 3/0 or “hello” + 2
Outputting to the screen
Remember – if you don’t tell the compiler what you want specifically you wont get it
cout << “ ******” ;
cout << “ ** “ ;
Will display ****** **
Not ******
**
cout << “******” << endl; //added the end line – also cascaded
cout <<“ ** “;
Will display ******
**
You can cascade many output statements as long as you remember the extraction operators << in between
cout << “ *******” << endl
<< “ ** “ << endl; // will work – notice new extraction operator and no ; until the end
Also remember your screen resolution my be different than the information you are compiling
Might not fir the way you want.
*********** *** * *
* * * * *** * *
* * * * ***** * *
* * * * * * *
* * * * * * *
* * * * * * *
* * * * * * *
* * * * * * *
*********** *** * *

More Related Content

What's hot (20)

PPT
My programming final proj. (1)
aeden_brines
 
PPTX
C to perl binding
Shmuel Fomberg
 
PDF
Practical TypeScript
ldaws
 
ODP
Perl In The Command Line
Marcos Rebelo
 
PPTX
Switch case and looping new
aprilyyy
 
PPT
02 Php Vars Op Control Etc
Geshan Manandhar
 
PPTX
PHP function
monikadeshmane
 
PPTX
Python Programming Essentials - M5 - Variables
P3 InfoTech Solutions Pvt. Ltd.
 
PPTX
C Programming Language Part 7
Rumman Ansari
 
PDF
JavaScript ES10 and React Js Introduction
Amanpreet Singh
 
PPTX
Kotlin For Android - Basics (part 1 of 7)
Gesh Markov
 
PPTX
Python Programming Essentials - M11 - Comparison and Logical Operators
P3 InfoTech Solutions Pvt. Ltd.
 
PDF
Knee-deep in C++ s... code
PVS-Studio
 
PPTX
Kotlin For Android - Constructors and Control Flow (part 2 of 7)
Gesh Markov
 
PDF
Lab 1: Compiler Toolchain
enidcruz
 
PPTX
Closures
prashanthbabu07
 
PPTX
C++ Programming Club-Lecture 1
Ammara Javed
 
PDF
Vim Hacks
Lin Yo-An
 
PPT
Introduction to C++,Computer Science
Abhinav Vishnoi
 
PDF
How do i - create a native interface
Shai Almog
 
My programming final proj. (1)
aeden_brines
 
C to perl binding
Shmuel Fomberg
 
Practical TypeScript
ldaws
 
Perl In The Command Line
Marcos Rebelo
 
Switch case and looping new
aprilyyy
 
02 Php Vars Op Control Etc
Geshan Manandhar
 
PHP function
monikadeshmane
 
Python Programming Essentials - M5 - Variables
P3 InfoTech Solutions Pvt. Ltd.
 
C Programming Language Part 7
Rumman Ansari
 
JavaScript ES10 and React Js Introduction
Amanpreet Singh
 
Kotlin For Android - Basics (part 1 of 7)
Gesh Markov
 
Python Programming Essentials - M11 - Comparison and Logical Operators
P3 InfoTech Solutions Pvt. Ltd.
 
Knee-deep in C++ s... code
PVS-Studio
 
Kotlin For Android - Constructors and Control Flow (part 2 of 7)
Gesh Markov
 
Lab 1: Compiler Toolchain
enidcruz
 
Closures
prashanthbabu07
 
C++ Programming Club-Lecture 1
Ammara Javed
 
Vim Hacks
Lin Yo-An
 
Introduction to C++,Computer Science
Abhinav Vishnoi
 
How do i - create a native interface
Shai Almog
 

Similar to Lesson 2 starting output (20)

PPT
intro to programming languge c++ for computer department
MemMem25
 
PPT
Practical basics on c++
Marco Izzotti
 
PPTX
Output in c++ (cout)
Ghada Shebl
 
PPTX
Intro To C++ - Class 03 - An Introduction To C++ Programming, Part II
Blue Elephant Consulting
 
PPTX
Intro To C++ - Class 3 - Sample Program
Blue Elephant Consulting
 
PPT
c++basics.ppt
TatyaTope4
 
PPT
c++basics.ppt
EPORI
 
PPT
c++basiccs.ppt
RaghavendraMR5
 
PPT
c++basics.ppt
Infotech27
 
PDF
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
GrejoJoby1
 
PPT
Fp201 unit2 1
rohassanie
 
PPT
C++basics
amna izzat
 
DOCX
lec4.docx
ismailaboshatra
 
PPTX
basic program
NIDA HUSSAIN
 
PPT
Beginner C++ easy slide and simple definition with questions
khawajasharif
 
PPTX
Project in programming
sahashi11342091
 
PPTX
Switch case and looping kim
kimberly_Bm10203
 
PDF
030 cpp streams
Hồ Lợi
 
PPTX
C++ AND CATEGORIES OF SOFTWARE
UNIVERSITY OF ENGINEERING AND TECHNOLOGY TAXILA
 
intro to programming languge c++ for computer department
MemMem25
 
Practical basics on c++
Marco Izzotti
 
Output in c++ (cout)
Ghada Shebl
 
Intro To C++ - Class 03 - An Introduction To C++ Programming, Part II
Blue Elephant Consulting
 
Intro To C++ - Class 3 - Sample Program
Blue Elephant Consulting
 
c++basics.ppt
TatyaTope4
 
c++basics.ppt
EPORI
 
c++basiccs.ppt
RaghavendraMR5
 
c++basics.ppt
Infotech27
 
C++ and OOPS Crash Course by ACM DBIT | Grejo Joby
GrejoJoby1
 
Fp201 unit2 1
rohassanie
 
C++basics
amna izzat
 
lec4.docx
ismailaboshatra
 
basic program
NIDA HUSSAIN
 
Beginner C++ easy slide and simple definition with questions
khawajasharif
 
Project in programming
sahashi11342091
 
Switch case and looping kim
kimberly_Bm10203
 
030 cpp streams
Hồ Lợi
 
C++ AND CATEGORIES OF SOFTWARE
UNIVERSITY OF ENGINEERING AND TECHNOLOGY TAXILA
 
Ad

Recently uploaded (20)

PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PDF
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PDF
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
PDF
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
PPTX
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
PDF
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
PPTX
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
PPTX
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
PPSX
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
Chapter-V-DED-Entrepreneurship: Institutions Facilitating Entrepreneurship
Dayanand Huded
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
grade 5 lesson matatag ENGLISH 5_Q1_PPT_WEEK4.pptx
SireQuinn
 
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Unit 2 COMMERCIAL BANKING, Corporate banking.pptx
AnubalaSuresh1
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
community health nursing question paper 2.pdf
Prince kumar
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
Dimensions of Societal Planning in Commonism
StefanMz
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 
Cultivation practice of Litchi in Nepal.pptx
UmeshTimilsina1
 
HEALTH ASSESSMENT (Community Health Nursing) - GNM 1st Year
Priyanshu Anand
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
Ad

Lesson 2 starting output

  • 2. Remember these they work in our editor Operation Key Combo Cut ctrl + x Copy ctrl + c Paste ctrl + v Save ctrl + s Undo ctrl + z
  • 3. //first program – this is a comment #include <iostream> int main() { return 0; } basic application review
  • 4. Some languages provide keywords to perform specific tasks for, class, int C++ uses functions and classes for just about everything A library called The Standard Library comes with your tools And the tools know where to find it Libraries
  • 5. #include<iostream> this includes a library that allows us to use the We use libraries all the time in programming You will be using many at times Operands insertion >> and extraction << operators cout << and cin >> std:: cout << //allows data to be read from the stream std::cin >> //allows data to be sent to the stream endl is the end line command (like hitting the enter key) We can use using namespace std; at the top of a program This allows us not to type std:: before every cout << or cin >> statement.
  • 6. cout << Output stream – anything following can be output to the screen Text is enclosed in “ “ and is considered a literal. Numbers are considered literals and print as they are. Expressions are evaluated and the result printed. cout << “hello”; displays the word hello to the screen. cout << 2; displays the number 2 cout << “2”; will work too. cout << 2 + 2; displays 4 cout << “2 + 2”; displays 2 + 2 cout << endl; drops to next line
  • 7. cout << “” is an escape sequence. The compiler is looking for another character to do something at that point. Sometimes you need to print a “” or a “ but they are part of the syntax so this allows you a way. Example cout << “hellonworld”; displays: hello world The n is for new line Others include Escape sequence character represented a Alarm (Beep, Bell) b Backspace f Formfeed n Newline (Line Feed) r Carriage Return t Horizontal Tab v Vertical Tab Backslash ' Single quotation mark " Double quotation mark ? Question mark
  • 8. Issues endl needs to be it’s own statement ex. Can’t be cout << “Hello” cout << endl; has to be cout << “Hello”; cout <<endl; or cout << “Hello”; cout << endl; Can be cascaded on the same cout without the semi colon - Best Way! ex. cout << “Hello” << endl; //makes it easier to follow as a programmer
  • 9. C++ runs in sequence so we need the libraries set as below – Top – Down Design #include <iostream> using namespace std; Notice the formatting – white space / indenting and next lines // this will run just fine but would be a nightmare to code and read #include <iostream> int main(){return 0;} //this is what we need #include <iostream> int main() { return 0; } Don’t ask for the impossible 3/0 or “hello” + 2
  • 10. Outputting to the screen Remember – if you don’t tell the compiler what you want specifically you wont get it cout << “ ******” ; cout << “ ** “ ; Will display ****** ** Not ****** ** cout << “******” << endl; //added the end line – also cascaded cout <<“ ** “; Will display ****** ** You can cascade many output statements as long as you remember the extraction operators << in between cout << “ *******” << endl << “ ** “ << endl; // will work – notice new extraction operator and no ; until the end Also remember your screen resolution my be different than the information you are compiling Might not fir the way you want.
  • 11. *********** *** * * * * * * *** * * * * * * ***** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *********** *** * *