Basics of C++ Programming: A Quick Overview
In this lecture by Mrs. Afreen Mukhtar Solkar, fundamental concepts of C++ programming are introduced. Topics covered include C++ statements, the main function, input/output operations using cout and cin, semicolons and blocks in C++, and the significance of whitespace in code formatting. The lecture emphasizes the importance of syntax and structure in C++ programming.
Download Presentation
Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
E N D
Presentation Transcript
LECTURE-2 By: Mrs. Afreen Mukhtar Solkar 1
cout<<Hello World; This line is a C++ statement. It is the statement that produce some effect in the program. C . ++ . The statement always ends with a semi colon (;). ( .) This character is used to mark the end of the statement. . return 0; The return statement causes the main function to finish. . 2
Every C++ must have main ( ). .)( { open braces, indicates beginning of body. . } closing braces, indicates ending of body. .. C ++ { } 3
cout :- this statement is used to print the string enclosed in quotation. : - . It is also used to print the value of the variable. . Example: cout<< welcome to computer center ; cout<< variable names ; The(<<)operator called insertion operator. . ) << ( 4
cin: -cin is used for inputting the value of variable Example :-cin>> a; , cin>> b; cin>> a >>b ; The operator >> is known as extraction operator, it extract the value. cin - : >> . 5
Semicolons & Blocks in C++ C ++ In C++, the semicolon is a statement terminator. . That is, each individual statement must be ended with a semicolon. . C ++ C ++ For example, following are three different statements: : x = y; y = y+1; add(x, y); 6
A block is a set of logically connected statements that are surrounded by opening and closing braces. . For example: { cout << "Hello World"; // prints Hello World return 0; } C++ does not recognize the end of the line as a terminator. For this reason, it does not matter where you put a statement in a line. . C ++ . 7
For example: x = y; y = y+1; add(x, y); is the same as x = y; y = y+1; add(x, y); 8
Whitespace in C++ C ++ A line containing only whitespace, with a comment, is known as a blank line, and C++ compiler totally ignores it. . Whitespace is the term used in C++ to describe blanks, tabs, newline characters and comments. C ++ C ++ . 9
Whitespace separates one part of a statement from another and enables the compiler to identify where one element in a statement, such as int, ends and the next element begins. . Statement 1: int age; In the above statement there must be at least one whitespace character (usually a space) between int and age for the compiler to be able to distinguish them. . ) ( 10
Statement 2: fruit = apples + oranges; // Get the total fruit In the above statement 2, no whitespace characters are necessary between fruit and =, or between = and apples, although you are free to include some if you wish for readability purpose. 2 = = . 11
Comments in C++ C ++ Program comments are explanatory statements that you can include in the C++ code. C ++ . These comments help anyone reading the source code. . All programming languages allow for some form of comments. . 12
C++ supports single-line and multi-line comments. C ++ . All characters available inside any comment are ignored by C++ compiler. C ++. C++ comments start with /* and end with */. For example: //* This is a comment *// //* C++ comments can also*// //* span multiple lines*// 13