Professional Documents
Culture Documents
C++ - Basic Syntax
C++ - Basic Syntax
Basic Syntax
About C++ Language
About C++ Language
Program Structure
C++ Program Structure
Comments
Preprocessor Directive
Namespace
Main function
Statments
C++ Data Types
C++ Variables
C++ Variable Definitions
C++ Keywords
C++ Keywords
C++ Operators
C++ Basic Input and Output
• When we say Input, it means to feed some data into a program. An
input can be given in the form of a file or from the command line.
Example:
int num = 0;
cin >> num; You will ask to input at the console screen.
C++ Basic Input and Output
• For input command, we will use cout <<.
Example:
int num = 2;
cout << num; The value “2” from num is displayed.
cout << “hello”; “hello” is displayed.
cout << “hi ” << “123” << “hello”; “hi 123hello” is displayed.
C++ Conditional Statements
• If the conditional statement is TRUE, the statement inside the
conditional scope is executed, otherwise it will not execute.