Author: Awais Farooq
-
Return Statement in C++
The return statement in C++ is used to exit a function and to send a value back to the function’s caller which is optional depending on requirement. It plays a very important role in controlling the flow of a program and making sure that functions will provide results to other parts of the code. Syntax Below is…
-
C++ Recursion (Recursive Function)
Recursion is a programming technique where a function calls itself over again and again with modified arguments until it reaches its base case, where the recursion stops. It breaks a problem down into smaller, more manageable sub-problems, recursion allows for elegant and better solutions to complex problems. Recursive Function A recursive function is a function…
-
Multiple Function Parameters in C++
C++ multiple function parameters describe the ability of a function to accept more than one argument or can say functions with multiple parameters to perform operations using several inputs, this feature makes a function to execute more complex operations by working with multiple subset of data at once. Syntax In C++, you can define a…
-
C++ Functions
A function is a group of statements that together perform a task. Every C++ program has at least one function, which is main(), and all the most trivial programs can define additional functions. You can divide up your code into separate functions. How you divide up your code among different functions is up to you, but…
-
C++ String Concatenation
String concatenation is the process of adding an element to an existing element. In this context, string concatenation is the method by which two (or more) strings can be added to one another. Hence, the resultant string is the combination of the initial string and the added string. There are several methods to concatenate strings…
-
C++ String Length
Length of a string is the number of characters present in the string. These characters can be of the data type char, and these include all alphanumeric elements, symbols and miscellaneous characters. In C++ programming language, there are two types of strings- Character Arrays of C-Style type, and String objects which are built-in objects of <string> class. The length of a string also includes…
-
C++ Strings
C++ provides following two types of string representations − The C-Style Character String The C-style character string originated within the C language and continues to be supported within C++. This string is actually a one-dimensional array of characters which is terminated by a null character ‘\0’. Thus a null-terminated string contains the characters that comprise the string…
-
Unions in C++
In C++, a union is a user-defined data type that allows you to store different data types in the same memory location. However, the union can store only one of its member variables at a time, which means that if you assign a value to one member, the previous value stored in another member is overwritten. Where the size…
-
C++ Structures (struct)
C/C++ arrays allow you to define variables that combine several data items of the same kind, but structure is another user defined data type which allows you to combine data items of different kinds. Structures are used to represent a record, suppose you want to keep track of your books in a library. You might want to…
-
C++ Date and Time
The C++ standard library does not provide a proper date type. C++ inherits the structs and functions for date and time manipulation from C. To access date and time related functions and structures, you would need to include <ctime> header file in your C++ program. There are four time-related types: clock_t, time_t, size_t, and tm. The types – clock_t,…