C++

C++ Function

Function In C++

Function in C++ : Function is defined as block of code which is used to perform a specific task. It can run only when we call it by its name in main function. Syntax for creating function in c++: void function_name(){statement 1;statement 2;} Example : #include <iostream.h>void sum(int a , int b){return a+b;}int main(){int x,y;cout<<”Enter …

Function In C++ Read More »

C++ Object

Object’s in C++

When a class is defined, only the specification for the object is defined, no memory or storage is allocated. To use the data and access functions defined in the class, you need to create objects. An object’s in c++ is known as instance of class.   Syntax for declaring object’s in c++ : class_name object …

Object’s in C++ Read More »

c++ classes

Classes in C++

Classes in C++ : An object oriented programming approach is a collection of objects and each object consists of corresponding data structures and procedures. The program is reusable and more maintainable. The important aspect in object oriented programming is a class which has similar syntax that of structure. It is a collection of data and …

Classes in C++ Read More »

c++ do-while loop

do-While loop in C++

The while loop does not allow body to be executed if test condition is false. The do-while loop is an exit controlled loop and its body is executed at least once. Syntax of do-while loop: do{statement;}while(Condition); Program 1.1: // C++ Program to print numbers from 1 to 5 #include <iostream>using namespace std;int main() {int i …

do-While loop in C++ Read More »

C++ While loop

While Loop in C++

While loop is an entry controlled loop. The condition is evaluated and if it is true then body of loop is executed. After execution of body the condition is once again evaluated and if is true body is executed once again. This goes on until test condition becomes false. Syntax of while loop: While (condition){statementstatement …

While Loop in C++ Read More »

C++ for loop

For loop in C++

It is an entry control loop which provides a more concise structure. Basically this loop is used when we know the starting and ending point. For Statement is further dived into three expression and these three are separated by semicolon (;): i) initialization expression is used to initialize variables.ii) test expression is responsible of continuing …

For loop in C++ Read More »

C++ Switch Statement

Switch Statement in C++

Switch Statement : When we have most than one valid choice or condition then, most programming languages provide another selection concept known as multiway selection. Multiway selection chooses among several alternatives. C ++ has two different ways to implement multiway selection: i.Switch Statementii. else-if statement Switch Statement : This is applicable when we have more …

Switch Statement in C++ Read More »