Posts

Showing posts with the label cpp

c++ continue statement

Image
c++ continue statement In this tutorial, we will learn about the continue statement in cpp language and it's usage in loop programming. In computer programming, the continue statement to break the execution in the loop and give control to the initial part of the loop.   The  syntax of the continue statement. continue; Before learning the continue statement, kindly go through the loops => while loop => do while loop => for loop how continue statement work? Example: #include<iostream> using namespace std; int main() { for(int num =0;num <=5;num++) { //if loop counter reach at value of 3  //then skip the lower part of the loop and  //return to top of loop for next //iteration if(num ==3) { continue;                //if num=3 then loop continue,return to the top of loop } cout<< num <<endl; } return 0; } Output 0 1 2 4 5 In the above example, the loop normally works until the condition meets counter=3. If counter=3

Function overloading c++

Image
Function overloading In this tutorial, you will understand the concept of function overloading in the c++ language and what are the advantages of function overloading. How to overload function in c++? Functions overload with the variation of arguments and data types of arguments with the same name of the function. The name of the function will be the same in all functions but different data types and numbers of arguments. The prototype of function decides the function's call during calling the function. First look at the function overloading with the different number of parameters in the parameter list. The parameter list : return data type function name (parameter 1,parameter 2,...) These parameters are also known as arguments. Function overload on the base of the numbers of parameters. Syntax : Function name fun . int fun(int a) int fun(int a,int b) int fun(int a,int b,int c) Example: #include<iostream> using namespace std; void fun(int a); void fun(int a,int b); void fun(i

Function types C++

 Types of user-defined function In this tutorial, you will learn about the different ways of using the function in the c++ language. You can use this technique to enhance your coding.   How many types of functions in the c++?   The following are the types of functions depend on the parameter list and return data type of the function. Function with no parameter and no return data type Function with return data type and no argument   Function with return type and argument Function with no parameter and no return data type: The function may have no parameter pass and no return type. The question is that what is the advantage of this type of function?. The answer may be to use the function for displaying something, it depends on the logic of the programmer. An example will be helpful to understand this kind of functions Example: #include<iostream> using namespace std; void display()                         //declare and define the display function { cout<<" The number is d

c++ function

Image
In this article, we will learn about the function in c++ and deep dive into the concept of functions. How to make, define, and use of functions in CPP language. Function in c++ The function is the block of code that performs a particular task. There are two types of functions in c++ language. Built-in function(pre defined function). The user defines a function. Let's take an example, find the square root of the number. This is a problem, we will create a program but we can also solve this problem by making a function.  If the predefined function is available in c++ language then we can use the function by calling easily but if the function is not available in the language then we shall make the user define a function. The user-defined function allows to user to make his own function and reuse his function whenever need function. Declaration of function in cpp: The syntax of declaration of the function: returntype functonname(parameter1,parameter2,parameter3,....) { /////////code }

operators in c++

In this article, you will learn about the operators in CPP.how to use and what are the functions of operators in c++. operator An operator is a symbol that tells the computer to perform a specific function. The function will be mathematical, and logical manipulation. There are many built-in operators in the CPP . The following are the types of operators that are using in c++. Arithmetic Operators Relational Operators Logical Operators Assignment Operators Bitwise Operators Arithmetic Operators Arithmetic operators use for the mathematical arithmetic tasks. The following are the operators that are supported by c++. Addition operator(+): The symbol(+) is used to adding two operands. The operands may be integers, float, and double. An example will be clear how to use this operator: Subtract operator(-) The symbol(-) is used to subtract the two operands. Subtract the second operand from the first operand. An example will be helping: Multiple operator(*) This symbol(*) is used to multiple t

2D array and multi dimensional array

Image
C++ multidimensional arrays In this article, you learn about the multidimensional array in cpp.you will learn accessing, initialization, and transverse the multidimensional arrays. The concept behind the array of arrays is just like that representation of array data in the tabular form, similar to the matrix form representation. Here the 2D array can store 15 elements. The array has the 3 rows and 5 columns. In the example array name is Ar. Every index of the array has the name just like the data in the variable has the name. These indexes used for accessing the data store in the array. In the above diagram, there is an array and every block of the array has a name like an array[row][col]. How to initialize the 2D array in cpp? Initialization of 2D array  int arr[2][3]={1,2,3,4,5,6}; This is not a good way to initialize the 2D array.following is the best way to initialize the multi-dimensional arrays. int arr[2][3]={{1,2,3} , {4,5,6}}; This array has two rows and three columns which me