
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 33676 Articles for Programming

477 Views
std::reference_wrapper is a class template in C++ that allows you to store references to objects or functions in a way that makes them copyable and assignable. Normally, C++ references can't be stored in standard containers like std::vector or std::list, because references are not copyable. std::reference_wrapper solves this problem by internally storing a pointer to the referenced object. It acts like a wrapper around a reference and behaves almost like the original object. It can be passed to functions that take T& (a reference to T), because std::reference_wrapper is implicitly convertible to T&. This is especially useful when you ... Read More

2K+ Views
The fork() system call is used to create a process commonly known as a child process if the fork() returns 0. Otherwise, the created process is known as the parent process. All processes created with fork() execute in parallel. But what if we want the last process to be executed first? In this case, the parent process would execute last because of bottom-to-top execution. This can be done using the wait() system call. The wait system call is used to process handling. It pauses the execution of the calling process until the child process has finished its execution. It's commonly ... Read More

731 Views
In this article, we will see why we should avoid the std::endl while printing lines into the console or a file. We use std::endl to create a new line after the current line. For a few lines of I/O operations, it is not causing any problems. However, a large number of I/O tasks decreases performance. Why We Avoid Using std::endl There are the following reasons to avoid endl: The endl is used to create new lines, but it does not send to the new line only; after sending the cursor to the next line, it ... Read More

4K+ Views
Here, we are going to learn how we can calculate the range of the different C++ data types such as signed data types (int, char, float, etc.) and unsigned data types (unsigned char, unsigned int, unsigned float, etc.). Calculating Range of Signed Data Types In C++, signed data types are used to represent both positive and negative integer values. So, to display their range, we use the following method − Calculate the total number of bits, multiply the sizeof bytes by 8. Calculate -2^(n-1) for minimum range ... Read More

1K+ Views
In this article, we will see how to print a character n times without using loops and recursion in C++. Input/Output Scenario Let's see following input output scenario − Input : n = 10, c = 'i' Output : iiiiiiiiii Input : n = 5, character = 'j' Output : jjjjj Using String Constructor Here, using the string constructor in C++ to print a character n times: It allows initialization of a string with multiple copies of a specific character by passing the number of times and the character itself as arguments. Example In this C++ example, we ... Read More

5K+ Views
What is Expression Tree?An expression tree is a binary tree used to represent expressions. In an expression tree, internal nodes correspond to operators, and each leaf node corresponds to an operand. Let's see an expression and construct a tree for [5 + ((4+3)*2)]. Constructing an Expression TreeOur task is to construct an expression tree from a prefix expression. We have given a character array arr[] representing a prefix expression, so we have to build an expression tree for the expression and then display the infix and postfix expressions of the created tree. Input/Output Scenario Following are the examples to ... Read More

3K+ Views
Array Class In C++, the array class is part of the standard library and is known for its fixed size. The C++ array class, introduced in C++11, offers a better alternative to C-style arrays. The following are the advantages of the array class over a C-style array: Array class knows its size, whereas a C-style array does not have its size. So when passing to functions, we don't need to pass the size of the array as a separate parameter. C-style array there is more risk of array being decayed into ... Read More

24K+ Views
Both vectors and arrays are used to store collections of elements, but they differ significantly in how they manage their memory and flexibility. C++ std::vector A vector is a dynamic array that can be resized automatically when elements are added or removed. It is a part of the C++ STL and provides more flexibility than a static array. Example In the following example, we will demonstrate the usage of the vector in C++ − #include #include using namespace std; int main() { vector > v { { 4, 5, 3}, {2, 7, 6}, {3, 2, 1, 10} }; cout

6K+ Views
In this article, we will see the differences between namespace and class in C++. Namespace and classes are two different concepts, so let's discuss them: Classes are datatypes. It is an expanded version of the structures. Classes can contain data members and functions as members, but namespaces can contain variables and functions by grouping them into one and cannot be created as objects; it is used as additional information to differentiate similar functions, classes, variables, etc. Variables, functions with the same name can be placed in different namespaces. What is Namespace? The namespace is a feature that provides a way ... Read More

2K+ Views
Here we will see what is dynamic memory allocation in C. The C programming language provides several functions for memory allocation and management. These functions can be found in the header file. The following functions for memory allocations.FunctionDescriptionvoid *calloc(int num, int size);This function allocates an array of num elements each of which size in bytes will be size.void free(void *address);This function releases a block of memory block specified by address.void *malloc(int num);This function allocates an array of num bytes and leave them uninitialized.void *realloc(void *address, int newsize);This function re-allocates memory extending it upto newsize.Allocating memory dynamicallyWhile programming, if you ... Read More