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++ | Character in C++ | Identifier in 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 …

Types of Constant in C++ | Types of Literals in C++ 

Preview

Length: 10 minutesComplexity: Easy

Types of Constant in C++ | Types of Literals in C++  What is a constant/literal 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/Literal Numeric Constants contain digits only. They are of two types Integer Constant Floating …

Escape Sequences in C++

Preview

Length: 10 minutesComplexity: Easy

Escape Sequences in C++ Escape Sequences in C++ are special character constants to represent non graphical characters in C++. Most common non graphical characters include enter key, backspace, tab etc. They start with a backward slash ( \  ) followed by a specific character. Most commonly used escape sequences in C++ are: 1)  \n    …

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 …

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                            …

Types of unary operators in C++

Preview

Length: 10 minutesComplexity: Easy

Types of unary operators in C++ Unary operators in C++ are those operators which have single operand. They are of following types: 1. Unary Plus operator in C++ (+) 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 …

Types of Increment operator in C++ | Types of Decrement operator in C++

Preview

Length: 10 minutesComplexity: Easy

Types of Increment operator in C++ | Types of 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 …

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++ 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++. Example: 1+4=5 ii. – …

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++ ?: 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? S1: S2; Condition is a conditional expression. S1 …

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++ 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: i. = It is used to assign some value to a variable. Example: n=10 …

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 …

3 types of Visibility modes in C++

Preview

Length: 10 minutesComplexity: Easy

3 types of Visibility modes in C++ These three visibility modes in C++ that specify how the members of the class are accessible inside a program. There are 3 types of Visibility modes in C++. Private Protected Public Private visibility mode in C++ This is the default visibility mode of class members in C++. Private …

Defining member functions inside or outside the class in C++

Preview

Length: 10 minutesComplexity: Easy

Defining member functions inside or outside the class  in C++ The member functions of a class can be defined in two ways:- Inside the class Outside the class Defining member functions inside the class  in C++ This is the most common way of defining members functions of a class. In this case we define member …

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++  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. //Program to demonstrate the use of sizeof() …

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

Preview

Length: 10 minutesComplexity: Easy

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; int a=10;         //Global Variable a int main() { …

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++  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 followed by operators with lower precedence. Example: While calculating expression 10-3*4. …

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 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 Automatic type conversion is, output of arithmetic expression will be 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++ is also called  type 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 C++. Expression is a valid arithmetic expression of …

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. …

Simple if statement in C++

Preview

Length: 0 minutes

Simple if statement in C++ Simple if statement in C++ 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 In simple if statement, there is only one Condition …

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 a relational …

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) Statement-Block-3;  else      Statement-Block-4; } Test-Condition-1, Test-Condition-2 and Test-Condition-3 are relational or logical expressions that are checked to execute …

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(Initialization;Condition;Updation) { Statements-Block; } for is a keyword of C++. Initialization 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 …

Inline functions in C++ | Inline member functions in C++

Preview

Length: 0 minutes

Inline functions in C++ | Inline member functions in C++ Inline functions are an enhancement provided by C++ to speed up the programs. The coding of normal functions and inline functions are same except that inline function’s definition starts with the keyword inline. With inline code, the compiler replaces the function call statement with the …

Friend function in C++ | Friend class in C++

Preview

Length: 0 minutes

Friend function in C++ | Friend class in C++ Friend Function in C++ Friend function in C++ is a special kind of function which is not a member of some class but it can access private as well as protected members of a class in indirect manner. Working of Friend function in C++ A non …

Defining a class in C++ | Declaring object in C++

Preview

Length: 0 minutes

Defining a class in C++ | Declaring object in C++ Class is defined as a user defined data type that contains variables called data members and functions known as member functions of the class. Syntax of declaring a class is: class  <class_name> { private:            [data members;]            [member functions] protected:            [data members;]            …