C++ Programming Notes

Lessons

Concepts of OOPS ( Object Oriented Programming System ) in C++

Preview

Length: 10 minutesComplexity: Easy

Concepts of OOPS ( Object Oriented Programming System ) in C++ Different concepts of OOPS are  as follows Object Anything having some properties and behavior is called an object. Example Bike is an object having properties like color, make, model. Behavior of bike includes speeding up the bike , applying brakes etc. In C++, object …

Structure of a C++ Program | Components of C++ Program

Preview

Length: 10 minutesComplexity: Easy

Structure of a C++ Program | Components of C++ Program Structure of a C++ Program contains different parts as follows Documentation Section Link Section Definition Section Global Declaration Section main() function Section Subprogram Section [User Defined Function Section] Documentation Section In this section we can specify the name of program along with details of developer …

Basic concepts of C++

Preview

Length: 10 minutesComplexity: Easy

Basic concepts of C++ Character Set of C++ These are the characters which we can use in C++ . Character set includes following characters Alphabets ( a-z, A-Z ) Digits (0-9) Special Characters ( #,+,-,*, \ , / etc.) White Spaces (Blank Space, Backspace, tab etc.) Token in C++ Smallest identifiable parts of a Program …

What is a variable in C++ | Declaration of variables in C++ 

Preview

Length: 10 minutesComplexity: Easy

What is a variable in C++ What is a variable in C++? A variable is the name given to some memory location . Variable can change its value during the execution of a C++ program. Rules to define a variable in C++   – Alphabets and digits both can be used. – Variable must start with …

Constant in C++ | Literals in C++ 

Preview

Length: 10 minutesComplexity: Easy

Constant in C++ | Literals in C++  What is a constant in C++? It is a quantity whose value we can’t change during the execution of program. They are of two types. Numeric Constant Character Constant Numeric Constant Numeric Constants contain digits only. They are of two types Integer Constant Floating point Constant Integer Constant …

Data Types in C++ | Primary Data Types of C++ 

Preview

Length: 10 minutesComplexity: Easy

Data Types in C++ | Primary Data Types of C++  What is a Data type in C++? Data type  specifies the type and range of values that can be stored in a variable. Different types of data types in C++ are Primary Data Types Derived Data Types User Defined Data Types Primary Data Types in …

Derived Data Types of C++ | Secondary Data Types of C++ 

Preview

Length: 10 minutesComplexity: Easy

Derived Data Types of C++ | Secondary Data Types of C++  What is Data type ? Data type gives the type and range of values that can be stored in a variable in C++. Different types of data types are Primary Data Types Derived Data Types User Defined Data Types DERIVED DATA TYPES OF C++ Derived …

User Defined Data Types of C++ | enumerated data type in C++ | typedef in C++

Preview

Length: 10 minutesComplexity: Easy

User Defined Data Types of C++ | enumerated data type in C++ | typedef in C++ What is Data type ? Data type gives the type and range of values that can be stored in a variable in C++. Different types of data types are Primary Data Types Derived Data Types User Defined Data Types User …

Operators in C++ | Types of operators in C++

Preview

Length: 10 minutesComplexity: Easy

Operators in C++ | Types of operators in C++ Operators in C++ Operator is a symbol in C++ to perform calculations and other manipulations on values. Operand Operand is defined as the values which are used for perform calculations or manipulations. Example: 10-5                            …

Unary operators in C++

Preview

Length: 10 minutesComplexity: Easy

Unary operators in C++ Unary operators in C++ are those operators which have single operand. They are of following types: 1. Unary Plus (+) This operator specifies that a number is positive. It is optional to put this operator before a number as a number without sign is considered positive automatically. Example: +14, 45  2. …

Increment operator in C++ | Decrement operator in C++

Preview

Length: 10 minutesComplexity: Easy

Increment operator in C++ | Decrement operator in C++ Increment operator in C++  ++ is known as Increment operator in C++. It adds one to the existing value of a variable of numeric or char type.  It can be used in two ways: Prefix Form of Increment operator in C++  In prefix form, increment operator …

Binary Operators in C++ | 5 Types of binary operators in C++

Preview

Length: 10 minutesComplexity: Easy

Binary Operators in C++ | 5 Types of binary operators in C++ Binary Operators in C++ These are the operators which can have two operands. 5 Types of binary operators in C++ Various categories of binary operators in C++ are: – Arithmetic Operators – Relational Operators – Logical Operators – Bitwise Operators – Shorthand Operators …

Arithmetic Operators in C++ | Types of Arithmetic operators in C++

Preview

Length: 10 minutesComplexity: Easy

Arithmetic Operators in C++ | Types of Arithmetic operators in C++ Arithmetic Operators in C++ Arithmetic Operators in C++ can do mathematical calculations on numeric values that may exist in the form of variables or constants. Different arithmetic operators in C++ are: i. + + is called Addition operator.  It can add numeric values in C++. …

6 Types of relational operators in C++

Preview

Length: 10 minutesComplexity: Easy

6 Types of relational operators in C++ There are 6 Types of relational operators in C++. They are used to compare numeric values. These values may be in the form of literals or variables.  The result of relational operator is either 1 or 0. i. <  < is known as Less than operator.  It checks …

3 Types of logical operators in C++

Preview

Length: 10 minutesComplexity: Easy

3 Types of logical operators in C++ Logical operators combine relational expressions. The output of a logical expression is always 1 or 0. There are 3 Types of logical operators in C++ as follows: i. Logical AND operator in C++ (&&) &&(Double Ampersand)  is known as  Logical AND  operator in C++.  If any input to …

Conditional Operator in C++ | Ternary operator in C++

Preview

Length: 10 minutesComplexity: Easy

Conditional Operator in C++ | Ternary operator in C++ Conditional Operator in C++ | Ternary operator in C++ ?: symbol represents conditional operator in C++. Conditional operator is also known as ternary operator as this operator has three operands.  It always tests a condition. Depending upon the result of condition, a specific instruction get executed. Syntax: Condition? …

Assignment operators in C++ | Shorthand operators in C++

Preview

Length: 10 minutesComplexity: Easy

Assignment operators in C++ | Shorthand operators in C++ Assignment operators in C++ | Shorthand operators in C++ Assignment operators in C++ are also known as shorthand operators in C++. They are used to update the existing value of a variable in an easy way. Various Assignment operators in C++ are: Operator Description Example = It is …

6 Types of bitwise operators in C++

Preview

Length: 10 minutesComplexity: Easy

6 Types of bitwise operators in C++ There are 6 Types of bitwise operators in C++. These operators can manipulate bits of a numeric value. These operator are:  **Value is converted into  into equivalent binary form before applying bitwise operators. i. Bitwise AND operator in C++  (&) & (ampersand sign) represents Bitwise AND operator in …

3 types of special operators in C++ | sizeof() in C++ | Comma operator in C++

Preview

Length: 10 minutesComplexity: Easy

3 types of special operators in C++  3 types of special operators in C++  These operators have special purpose in C++. Special operators in C++ are : – sizeof() – Comma (,) – Scope resolution operator (::) i. sizeof() in C++ sizeof() finds the size of a data type or value in term of bytes. …

Working of scope resolution operator in C++ (::)

Preview

Length: 10 minutesComplexity: Easy

Working of scope resolution operator in C++ (::) Working of scope resolution operator in C++ (::) :: (Double colon) represents scope resolution operator in C+.  It can be used in multiple ways in C++. i. To refer global variables Scope resolution operator in C++can refer global variable in a C++ program. #include<iostream> using namespace std; …

Precedence of operators in C++ | Associativity of operators in C++ 

Preview

Length: 10 minutesComplexity: Easy

Precedence of operators in C++ | Associativity of operators in C++  Precedence of operators in C++ | Associativity of operators in C++  i. Precedence of operators in C++ Precedence is the priority given to  each operator. Multiple operator in an expression get evaluated depending upon their precedence i.e. operator having higher precedence gets evaluated first …

Implicit type conversion in C++ | Automatic type conversion in C++

Preview

Length: 10 minutesComplexity: Easy

Implicit type conversion in C++ | Automatic type conversion in C++ Implicit type conversion in C++ | Automatic type conversion in C++ Implicit conversion in C++ is also called automatic type conversion in C++. It is the process in which output of arithmetic expression automatically gets converted into a specific data type. Basic rule of …

Explicit type conversion in C++ | Type casting in C++

Preview

Length: 10 minutesComplexity: Easy

Explicit type conversion in C++ | Type casting in C++ Explicit type conversion in C++ | Type casting in C++ Explicit type conversion in C++ is also called  casting. We can use casting to convert output of an arithmetic expression into a specific data type . Syntax (Data_Type) Expression Data_Type is any valid data type of …

cin statement in C++ | Read input in C++

Preview

Length: 10 minutesComplexity: Easy

cin statement in C++ | Read input in C++ cin stands for console input.  cin statement in C++ is used to read input from keyboard. cin is an instance of the istream It can be used to read value of a variable. It is followed by extraction operator (>>) followed by a variable whose value you want …

Comments in C++ | Single line comments in C++ | Multiline comments in C++

Preview

Length: 10 minutesComplexity: Easy

Comments in C++ | Single line comments in C++ | Multiline comments in C++ Comments in C++ Comments are user defined messages written by a programmer inside a program. Comments can be used to mention program name, program’s purpose or any information which can be helpful at a later stage for review of the program. Compiler …

cout statement in C++ | Display output in C++ 

Preview

Length: 10 minutesComplexity: Easy

cout statement in C++ | Display output in C++  cout stands for console output. cout statement in C++ is used to display value of a variable or a literal. cout statement is an instance of ostream class. It is followed by insertion operator (<<) followed by a variable or a literal that you want to …

C++ Basic Input/Output | Display output in C++

Preview

Length: 0 minutes

C++ Basic Input/Output | Display output in C++ There are different statements and functions to Display output in C++. They are as follows: cout write() put() 1. cout statement in C++ We can use  cout statement in C++ to display output.  It can be used to display a value of any primary data type. like …

C++ Basic Input/Output | Read input in C++

Preview

Length: 0 minutes

C++ Basic Input/Output | Read input in C++ There are different statements and functions to Display output in C++. They are as follows: cin get() getline() 1. cin statement in C++ We can use  cin statement in C++ to read input from keyboard.  It can be used to read value of any primary data type. …

Simple if statement in C++

Preview

Length: 0 minutes

Simple if statement in C++ Simple if statement in C language is a very powerful decision making statement and it is used to control the flow of execution of statements. There are four types of if statement: Simple if If else Nested if If else if ladder Simple if statement in C++  In simple if …

Control Structures in C++ | Control statements in C++ | Selection statements in C++ | Types of Looping in C++

Preview

Length: 0 minutes

Control Structures in C++ | Control statements in C++ | Selection statements in C++ | Types of Looping in C++ Control structure can be used to alter the normal flow of a program depending upon some Condition. Control structures can be categorized into three types: Selection Statements Iterative/Looping Statements Jumping Statements 1. Selection statements in …

if else statement in C++

Preview

Length: 0 minutes

if else statement in C++  In if else statement, there is only one condition. If  condition is true, one set of statements will be executed otherwise another set of statements will be executed. Syntax of if else statement in C++ is: if(Test-Condition) {   Statement-Block1; } else {   Statement-Block2; } Test-Condition is any conditional …

Nested if statement in C++

Preview

Length: 0 minutes

Nested if statement in C++ In nested if statement, one if statement block is enclosed within another if statement block. The syntax of nested if statement is: if(Test-Condition-1) {             if(Test-Condition-2)             Statement-Block-1;             else                  Statement-Block-2; } else {             if(Test-Condition-3)       …

if else if ladder statement in C++ | ladder if statement in C++

Preview

Length: 0 minutes

if else if ladder statement in C++ | ladder if statement in C++ It is a multi way decision making statement in which there are multiple conditions one after another. Depending upon these conditions, specific sets of statements are executed. The syntax of if else if ladder statement is: if(Test-Condition1) { Statement-Block-1; } else if(Test-Condition2)      …

switch statement in C++ | Working of switch statement in C++

Preview

Length: 0 minutes

switch statement in C++ | Working of switch statement in C++ It is a selection statement that works with a variable or expression of short, long, int or char data type whose value is compared with a list of values known as cases. If  value of expression/variable matches with any of the case value, the …

for statement in C++| Nesting of for statement in C++ | for loop in C++

Preview

Length: 0 minutes

for statement in C++| Nesting of for statement in C++ | for loop in C++ for statement is a looping statement used to repeat a set of statements for a specified number of times. Syntax of for statement is: for(Initialize;Condition;Update) { Statements-Block; } for is a keyword of C++. Initialize is the way to store …

do while statement in C++ | do while loop in C++

Preview

Length: 0 minutes

do while statement in C++ | do while loop in C++ In do while statement initialization, condition and updation are performed in separate lines. This looping statement executes at least once. The syntax of do while statement is: Initialization; do { Statements; updation; } while(Condition); do is a keyword which specifies that do while statement …