A loop inside another loop is called a nested loop. The number of loops depend on the complexity of a problem. Suppose, a loop, outer loop, running n number of times consists of another loop inside it, inner loop, running m number of times. Then, for each execution of the outer loop from 1...n, the inner loop runs maximum of m times.
Exceptions are runtime anomalies that a program encounters during execution. It is a situation where a program has an unusual condition and the section of code containing it can't handle the problem. Exception includes condition such as division by zero, accessing an array outside its bound, running out of memory, etc.
A C++ program can structurally be divided into different sections. Most sections are present by convention for developers to better understand a program. But there are some, which need to be followed in the order given. Primarily, a C++ program can be divided into
In C++ programming, loop is a process of repeating a group of statements until a certain condition is satisfied. Like while loop, for loop is an entry controlled loop, where entry controlled means the condition is checked at the beginning of loop. For loop is suitable to use when the number of times a loop runs is known or fixed.
In C++ programming, loop is a process of repeating a group of statements until a certain condition is satisfied. Do-while loop is a variant of while loop where the condition isn't checked at the top but at the end of the loop, known as exit controlled loop.
In every programming language including C++, loop is a process of repeating a group of statements until a certain condition is satisfied. While loop is an entry controlled loop where the condition is checked at the beginning of the loop. The condition to be checked can be changed inside it. The control can exit a loop in two ways, when the condition becomes false or using break statement.
The switch...case statement is a multiple branching statement where the control is transferred to one of the many possible conditions by checking the value of a variable or an expression. The switch statement consists of different cases inside it and the statements inside the case matching the condition is executed. If no cases are matched, the statements inside default block are executed.
While writing computer programs, we need to check certain condition to instruct the program to branch accordingly. Like most of the programming languages, C++ has if statement to check the condition and make decision. Based on the number of conditions to be checked, we have different types of if statement. They are
Inline function is a function which when invoked requests the compiler to replace the calling statement with its body. A keyword inline is added before the function name to make it inline. It is an optimization technique used by the compilers as it saves time in switching between the functions otherwise. Member functions of a class are inline by default even if the keyword inline is not used.
Inheritance is the process of inheriting properties of objects of one class by objects of another class. The class which inherits the properties of another class is called Derived or Child or Sub class and the class whose properties are inherited is called Base or Parent or Super class.