SlideShare ist ein Scribd-Unternehmen logo
1 von 44
[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object]
[object Object],[object Object],[object Object]
[object Object]
[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object]
[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object]
[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object]
[object Object]
[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object]
1. Comments 2. Load  <iostream> 3.  main 3.1 Print  &quot;Welcome to C++&quot; 3.2 exit ( return 0 ) Program Output Hello World ! 1 // firstcpp.cpp 2 // A first program in C++ 3 #include  <iostream> 4 5 int  main() 6 { 7   cout << ”Hello World!&quot;; 8 9   return  0;  // indicate that program ended successfully 10 } preprocessor directive   Message to the C++ preprocessor. Lines beginning with  #  are  preprocessor  directives. #include <iostream>  tells the preprocessor to include the contents of the file  <iostream> , which includes input/output operations (such as printing to the screen). Comments Written between  /*  and  */  or following a  // . Improve program readability and do not cause the computer to perform any action. C++ programs contain one or more functions, one of which must be  main Parenthesis are used to indicate a function int  means that  main  &quot;returns&quot; an integer value.  A left brace  {   begins the body of every function and a right brace  }  ends it. Prints the  string  of characters contained between the quotation marks.  The entire line, including  std::cout , the  <<   operator ,  the  string   ”Hello World !&quot;  and the  semicolon  ( ; ), is called a  statement . All statements must end with a semicolon. return  is a way to exit a function from a function. return 0 , in this case, means that the program terminated normally.
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object]
1. Load  <iostream> 2.  main 2.1 Print  &quot;Welcome&quot; 2.2 Print  &quot;to C++!&quot; 2.3 newline 2.4 exit ( return 0 ) Program Output Hello World !   1 // firstcpp.cpp 2 // Printing a line with multiple statements 3 #include  <iostream> 4 5 int  main() 6 { 7   std::cout << ”Hello &quot;; 8   std::cout << ”World !&quot;; 9 10   return  0;  // indicate that program ended successfully 11 } Unless new line  ''  is specified, the text continues on the same line.
1. Load  <iostream> 2.  main 2.1 Print  &quot;Welcome&quot; 2.2 newline 2.3 Print  &quot;to&quot; 2.4 newline 2.5 newline 2.6 Print  &quot;C++!&quot; 2.7 newline 2.8 exit ( return 0 ) Program Output Hello   World !  1 // firstcpp.cpp 2 // Printing multiple lines with a single statement 3 #include  <iostream> 4 5 int  main() 6 { 7   std::cout << ”Hello World !&quot;; 8 9   return  0;  // indicate that program ended successfully 10 } Multiple lines can be printed with one statement.
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Enter first integer 45 Enter second integer 72 Sum is 117 1 // Add.cpp 2 // Addition program 3 #include  <iostream> 4 5 int  main() 6 { 7   int  integer1, integer2, sum;  // declaration 8 9   cout << &quot;Enter first integer&quot;;  // prompt 10   cin >> integer1;  // read an integer 11   cout << &quot;Enter second integer&quot;;  // prompt 12   cin >> integer2;  // read an integer 13   sum = integer1 + integer2;  // assignment of sum 14   cout << &quot;Sum is &quot; << sum << endl;  // print sum 15 16   return  0;  // indicate that program ended successfully 17 } Notice how  cin  is used to get user input. Variables can be output using  cout << variableName . endl  flushes the buffer and prints a newline.
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object]

Weitere ähnliche Inhalte

Was ist angesagt?

C++ programming language basic to advance level
C++ programming language basic to advance levelC++ programming language basic to advance level
C++ programming language basic to advance levelsajjad ali khan
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeksAashutoshChhedavi
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointJavaTpoint.Com
 
Chapter3
Chapter3Chapter3
Chapter3Kamran
 
C basics 4 std11(GujBoard)
C basics 4 std11(GujBoard)C basics 4 std11(GujBoard)
C basics 4 std11(GujBoard)indrasir
 
C program report tips
C program report tipsC program report tips
C program report tipsHarry Pott
 
SULTHAN's - C Programming Language notes
SULTHAN's - C Programming Language notesSULTHAN's - C Programming Language notes
SULTHAN's - C Programming Language notesSULTHAN BASHA
 
Notes of c programming 1st unit BCA I SEM
Notes of c programming  1st unit BCA I SEMNotes of c programming  1st unit BCA I SEM
Notes of c programming 1st unit BCA I SEMMansi Tyagi
 
4. programing 101
4. programing 1014. programing 101
4. programing 101IEEE MIU SB
 
Top C Language Interview Questions and Answer
Top C Language Interview Questions and AnswerTop C Language Interview Questions and Answer
Top C Language Interview Questions and AnswerVineet Kumar Saini
 
Fundamentals of programming final santos
Fundamentals of programming final santosFundamentals of programming final santos
Fundamentals of programming final santosAbie Santos
 
Advanced C Language for Engineering
Advanced C Language for EngineeringAdvanced C Language for Engineering
Advanced C Language for EngineeringVincenzo De Florio
 

Was ist angesagt? (20)

C++ programming language basic to advance level
C++ programming language basic to advance levelC++ programming language basic to advance level
C++ programming language basic to advance level
 
C language introduction geeksfor geeks
C language introduction   geeksfor geeksC language introduction   geeksfor geeks
C language introduction geeksfor geeks
 
C_Programming_Notes_ICE
C_Programming_Notes_ICEC_Programming_Notes_ICE
C_Programming_Notes_ICE
 
C Programming
C ProgrammingC Programming
C Programming
 
C Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpointC Programming Language Tutorial for beginners - JavaTpoint
C Programming Language Tutorial for beginners - JavaTpoint
 
Chapter3
Chapter3Chapter3
Chapter3
 
C basics 4 std11(GujBoard)
C basics 4 std11(GujBoard)C basics 4 std11(GujBoard)
C basics 4 std11(GujBoard)
 
C program report tips
C program report tipsC program report tips
C program report tips
 
SULTHAN's - C Programming Language notes
SULTHAN's - C Programming Language notesSULTHAN's - C Programming Language notes
SULTHAN's - C Programming Language notes
 
The basics of c programming
The basics of c programmingThe basics of c programming
The basics of c programming
 
Unit4
Unit4Unit4
Unit4
 
Notes of c programming 1st unit BCA I SEM
Notes of c programming  1st unit BCA I SEMNotes of c programming  1st unit BCA I SEM
Notes of c programming 1st unit BCA I SEM
 
4. programing 101
4. programing 1014. programing 101
4. programing 101
 
Top C Language Interview Questions and Answer
Top C Language Interview Questions and AnswerTop C Language Interview Questions and Answer
Top C Language Interview Questions and Answer
 
C fundamentals
C fundamentalsC fundamentals
C fundamentals
 
Fundamentals of programming final santos
Fundamentals of programming final santosFundamentals of programming final santos
Fundamentals of programming final santos
 
Intro cpp
Intro cppIntro cpp
Intro cpp
 
Introduction to c programming
Introduction to c programmingIntroduction to c programming
Introduction to c programming
 
Advanced C Language for Engineering
Advanced C Language for EngineeringAdvanced C Language for Engineering
Advanced C Language for Engineering
 
C sharp
C sharpC sharp
C sharp
 

Andere mochten auch

Andere mochten auch (7)

Lecture 5
Lecture 5Lecture 5
Lecture 5
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Lecture 6
Lecture 6Lecture 6
Lecture 6
 
How technology has changed film
How technology has changed filmHow technology has changed film
How technology has changed film
 
Debates
DebatesDebates
Debates
 
Quiz1
Quiz1Quiz1
Quiz1
 

Ähnlich wie Lecture 1

Complete C++ programming Language Course
Complete C++ programming Language CourseComplete C++ programming Language Course
Complete C++ programming Language CourseVivek chan
 
Switch case and looping new
Switch case and looping newSwitch case and looping new
Switch case and looping newaprilyyy
 
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medinaFundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medinarurumedina
 
Macasu, gerrell c.
Macasu, gerrell c.Macasu, gerrell c.
Macasu, gerrell c.gerrell
 
My programming final proj. (1)
My programming final proj. (1)My programming final proj. (1)
My programming final proj. (1)aeden_brines
 
[C++][a] tutorial 2
[C++][a] tutorial 2[C++][a] tutorial 2
[C++][a] tutorial 2yasir_cesc
 
Switch case and looping kim
Switch case and looping kimSwitch case and looping kim
Switch case and looping kimkimberly_Bm10203
 
Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!olracoatalub
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and loopingChaAstillas
 
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 IIBlue Elephant Consulting
 
C language UPTU Unit3 Slides
C language UPTU Unit3 SlidesC language UPTU Unit3 Slides
C language UPTU Unit3 SlidesRakesh Roshan
 

Ähnlich wie Lecture 1 (20)

Lecture 2
Lecture 2Lecture 2
Lecture 2
 
Complete C++ programming Language Course
Complete C++ programming Language CourseComplete C++ programming Language Course
Complete C++ programming Language Course
 
Switch case looping
Switch case loopingSwitch case looping
Switch case looping
 
Switch case and looping new
Switch case and looping newSwitch case and looping new
Switch case and looping new
 
Fundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medinaFundamentals of prog. by rubferd medina
Fundamentals of prog. by rubferd medina
 
My final requirement
My final requirementMy final requirement
My final requirement
 
Macasu, gerrell c.
Macasu, gerrell c.Macasu, gerrell c.
Macasu, gerrell c.
 
My programming final proj. (1)
My programming final proj. (1)My programming final proj. (1)
My programming final proj. (1)
 
Switch case and looping jam
Switch case and looping jamSwitch case and looping jam
Switch case and looping jam
 
[C++][a] tutorial 2
[C++][a] tutorial 2[C++][a] tutorial 2
[C++][a] tutorial 2
 
A tutorial on C++ Programming
A tutorial on C++ ProgrammingA tutorial on C++ Programming
A tutorial on C++ Programming
 
Switch case and looping kim
Switch case and looping kimSwitch case and looping kim
Switch case and looping kim
 
Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!
 
Programming in C
Programming in CProgramming in C
Programming in C
 
Switch case and looping
Switch case and loopingSwitch case and looping
Switch case and looping
 
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
 
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
 
Python for Beginners(v2)
Python for Beginners(v2)Python for Beginners(v2)
Python for Beginners(v2)
 
C Programming Unit-2
C Programming Unit-2C Programming Unit-2
C Programming Unit-2
 
C language UPTU Unit3 Slides
C language UPTU Unit3 SlidesC language UPTU Unit3 Slides
C language UPTU Unit3 Slides
 

Kürzlich hochgeladen

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterMateoGardella
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 

Kürzlich hochgeladen (20)

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Gardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch LetterGardella_PRCampaignConclusion Pitch Letter
Gardella_PRCampaignConclusion Pitch Letter
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 

Lecture 1

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33. 1. Comments 2. Load <iostream> 3. main 3.1 Print &quot;Welcome to C++&quot; 3.2 exit ( return 0 ) Program Output Hello World ! 1 // firstcpp.cpp 2 // A first program in C++ 3 #include <iostream> 4 5 int main() 6 { 7 cout << ”Hello World!&quot;; 8 9 return 0; // indicate that program ended successfully 10 } preprocessor directive Message to the C++ preprocessor. Lines beginning with # are preprocessor directives. #include <iostream> tells the preprocessor to include the contents of the file <iostream> , which includes input/output operations (such as printing to the screen). Comments Written between /* and */ or following a // . Improve program readability and do not cause the computer to perform any action. C++ programs contain one or more functions, one of which must be main Parenthesis are used to indicate a function int means that main &quot;returns&quot; an integer value. A left brace { begins the body of every function and a right brace } ends it. Prints the string of characters contained between the quotation marks. The entire line, including std::cout , the << operator , the string ”Hello World !&quot; and the semicolon ( ; ), is called a statement . All statements must end with a semicolon. return is a way to exit a function from a function. return 0 , in this case, means that the program terminated normally.
  • 34.
  • 35.
  • 36.
  • 37. 1. Load <iostream> 2. main 2.1 Print &quot;Welcome&quot; 2.2 Print &quot;to C++!&quot; 2.3 newline 2.4 exit ( return 0 ) Program Output Hello World ! 1 // firstcpp.cpp 2 // Printing a line with multiple statements 3 #include <iostream> 4 5 int main() 6 { 7 std::cout << ”Hello &quot;; 8 std::cout << ”World !&quot;; 9 10 return 0; // indicate that program ended successfully 11 } Unless new line '' is specified, the text continues on the same line.
  • 38. 1. Load <iostream> 2. main 2.1 Print &quot;Welcome&quot; 2.2 newline 2.3 Print &quot;to&quot; 2.4 newline 2.5 newline 2.6 Print &quot;C++!&quot; 2.7 newline 2.8 exit ( return 0 ) Program Output Hello   World ! 1 // firstcpp.cpp 2 // Printing multiple lines with a single statement 3 #include <iostream> 4 5 int main() 6 { 7 std::cout << ”Hello World !&quot;; 8 9 return 0; // indicate that program ended successfully 10 } Multiple lines can be printed with one statement.
  • 39.
  • 40.
  • 41.
  • 42.
  • 43.
  • 44.

Hinweis der Redaktion

  1. 09/22/09 Programming Languages C Plus Plus
  2. 09/22/09 Programming Languages C Plus Plus
  3. 09/22/09 Programming Languages C Plus Plus
  4. The IF statement selects or ignores a single action. 09/22/09 Programming Languages C Plus Plus
  5. 09/22/09 Programming Languages C Plus Plus
  6. 09/22/09 Programming Languages C Plus Plus
  7. 09/22/09 Programming Languages C Plus Plus
  8. 09/22/09 Programming Languages C Plus Plus
  9. 09/22/09 Programming Languages C Plus Plus
  10. 09/22/09 Programming Languages C Plus Plus
  11. 09/22/09 Programming Languages C Plus Plus
  12. 09/22/09 Programming Languages C Plus Plus
  13. 09/22/09 Programming Languages C Plus Plus
  14. 09/22/09 Programming Languages C Plus Plus
  15. 09/22/09 Programming Languages C Plus Plus
  16. 09/22/09 Programming Languages C Plus Plus
  17. 09/22/09 Programming Languages C Plus Plus
  18. 09/22/09 Programming Languages C Plus Plus
  19. Most often, labels are simple int or char constants, such as 1or ‘q’ 09/22/09 Programming Languages C Plus Plus
  20. Most often, labels are simple int or char constants, such as 1or ‘q’ 09/22/09 Programming Languages C Plus Plus
  21. 09/22/09 Programming Languages C Plus Plus
  22. 09/22/09 Programming Languages C Plus Plus
  23. 09/22/09 Programming Languages C Plus Plus
  24. 09/22/09 Programming Languages C Plus Plus
  25. 09/22/09 Programming Languages C Plus Plus
  26. 09/22/09 Programming Languages C Plus Plus
  27. 09/22/09 Programming Languages C Plus Plus
  28. 09/22/09 Programming Languages C Plus Plus
  29. 09/22/09 Programming Languages C Plus Plus
  30. 09/22/09 Programming Languages C Plus Plus
  31. 09/22/09 Programming Languages C Plus Plus
  32. 09/22/09 Programming Languages C Plus Plus