CPP Array to Function

Arguments are the variables, inside the parentheses, after the function name which is used to pass informations to functions. Beside passing variables and pointers, arrays can also be passed as a function parameter or argument. Syntax: Return_type functionName (Data_type array Name[]) {     code to be executed; } Example: #include <iostream.h> using namespace std;   … Read more

Categories CPP

CPP Arrays

An array is a single variable which can store multiple values at a time. Thus, CPP array is used to hold many values under a single name. These values can be accessed then by referring to their index number. There are mainly two types of arrays: 1D array and multidimensional array. Syntax: data_type arrayName [arraySize]; … Read more

Categories CPP

CPP Storage Classes

A Storage class in CPP represents the scope of a variable within the program. The storage classes in CPP are discussed below:   Storage Classes Storage Place Default Value Scope Life-time Features auto RAM Garbage Local Within function Default storage class. extern RAM 0 Global Till the end of main program Visible to all the … Read more

Categories CPP

Recursion in CPP

When a function calls itself within its function block, it is called as self calling by a function. This whole process of self calling by a function is often termed as Recursion. Recursion is used to create a loop like behavior using a function and without using loop statements. Syntax: Return_type function_Name(parameters) { code to … Read more

Categories CPP

CPP Call: Value & Reference

Calling a function in CPP and passing values to that function can be done in two ways: Call by Value Call by Reference   Call by Value Call by Reference Original value of the function parameter is not modified. Original value of the function parameter is modified. In this method, we pass a copy of … Read more

Categories CPP

CPP Functions

A function is a piece of code that can be used repeatedly in a CPP program. A function is mainly of two types: Built in Functions; which are already defined in CPP Library. User Defined Functions; which are created and defined by users.   Syntax: Return_type functionName(parameters) {     code to be executed; }   … Read more

Categories CPP

CPP Comments

CPP comments are used to give a brief description about any specific line of code or about a module in the code to make the code more user-friendly. CPP Comments can be of two types: Single line Comments Multi line Comments   Single Line Comments: Single line comments can be used for commenting a line … Read more

Categories CPP

CPP Goto

CPP goto statement is used to jump to an specified label in the code every time, without any condition. Syntax: loop/conditions statements { statements; goto; }   Example: #include <iostream.h> using namespace std;   int main() { int n; cout << "Enter a number: "; cin >> n; if (n < 5) goto less; else … Read more

Categories CPP

CPP Continue

CPP Continue statement is used to skip the execution of current iteration in between the loop. Continue statement controls the containing loop only, i.e, external loops will not get affected because of Continue statement in inner loop.   Syntax: loop/conditions statements { statements; continue; }   Example: #include <iostream.h> using namespace std; int main() { … Read more

Categories CPP

CPP Break

CPP break statement is used to break the execution of current loop in between the loop or to prevent the code to check the next switch case. Break statement breaks the continuity of the containing loop only, i.e, external loops will not get affected because of Break statement in inner loop.   Syntax:   loop/conditions … Read more

Categories CPP