Basic C++ Structure PDF
Document Details
Uploaded by BestKnownHeather
Tags
Summary
This document provides an introduction to C++ programming concepts, including basic structure and comments. It outlines learning outcomes and explains the basic elements of a C++ program.
Full Transcript
Basic Structure of a C++ Program Learning Outcomes comment...
Basic Structure of a C++ Program Learning Outcomes comment #include // Required for cout, endl. #include // Required for sqrt() At the end of this lecture, you should be able to: using namespace std; // Tells which namespace to use Use to write document parts (notes) of the program. comments Identify basic structure of C++ program (pg 3) // Define and initialize global variables. double x1=1, y1=5, x2=4, y2=7; Comments help people read programs: Indicate the purpose of the program Basic Element C++ int main() function named main Describe the concepts of : { beginning of block for main // Define local variables. Describe the use of variables Character set. (pg 11) double side1, side2, distance; // Compute sides of a right triangle. side1 = x2 - x1; Explain complex sections of code Token (pg 13): keyword, identifiers, operator, side2 = y2 - y1; distance = sqrt(side1*side1 + side2*side2); Are ignored by the compiler. punctuation, string literal 6 // Print distance. string literal cout