
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 7197 Articles for C++

93K+ Views
A queue is a linear data structure that contains a collection of elements. Queue implements the FIFO mechanism i.e., the element that is inserted first is also deleted first. In other words, the least recently added element is removed first in a queue. Implementation Steps Based on the below implementation. Here are the steps to implement queue using array: Initialize Queue: Create an array queue[100] and set front and rear to -1 to indicate an empty queue. Predefine Input Values: Store input elements in input_values[] for insertion. ... Read More

358 Views
The atan2() function returns the tangent inverse of the coordinate in terms of y and x. Here y and x are the values of the y and x coordinates respectively. It is an inbuilt function in C++ STL.The syntax of the atan2() function is given as follows.atan2(dataType var1, dataType var2)As can be seen from the syntax, the function atan2() accepts two parameters var1 and var2 of data type float, double or long double that are y and x point respectively.The value returned by atan2() is in the range of -pi to pi and is the angle between the (x, y) ... Read More

1K+ Views
The acos() function returns the inverse cosine of an angle given in radians. It is an inbuilt function in C++ STL.The syntax of the acos() function is given as follows.acos(var)As can be seen from the syntax, the function acos() accepts a parameter var of data type float, double or long double. The value of this parameter should be between -1 and 1. It returns the inverse cosine of var in the range of -pi to pi.A program that demonstrates acos() in C++ is given as follows.Example Live Demo#include #include using namespace std; int main() { double d = ... Read More

175K+ Views
A stack is an abstract data structure that contains a collection of elements. Stack implements the LIFO mechanism i.e. the element that is pushed at the end is popped out first. Some of the principle operations in the stack are −Push - This adds a data value to the top of the stack.Pop - This removes the data value on top of the stackPeek - This returns the top data value of the stackA program that implements a stack using array is given as follows.Example#include using namespace std; int stack[100], n=100, top=-1; void push(int val) { if(top>=n-1) ... Read More

39K+ Views
A Doubly Linked List is a data structure made up of nodes created using self-referential structures. Each node contains three parts, namely the data, a pointer to the next node, and a pointer to the previous node. Also, the doubly linked list can be traversed in both forward and backward directions. Only the reference to the first node is required to access the whole linked list. This is known as the head. The last node in the list points to nothing, so it stores NULL in that part. In this article, we will write a C++ program to ... Read More

14K+ Views
A circular singly linked list is a type of data structure that is made up of nodes that are created using self-referential structures. Each node contains two components, namely the data element and the reference to the next node in the list. Only the reference to the head node is required to access the whole linked list. The last node of the list points to the head node, which makes it a circular linked list. Let's see a diagram of circular linked list. Circular linked lists are mainly useful for scheduling tasks and managing playlists, enabling smooth navigation. ... Read More

90K+ Views
A singly linked list is a type of data structure where each item (called a node) has two parts: the data and a link to the next node in the list. You start from the first node (called the head) and keep going until the link is empty (NULL). For example, let's understand with this list of numbers: 9 -> 2 -> 7 -> 1 -> 3 -> NULL In this case, the node containing 9 is the head, and the node containing 3 is the last node (its next pointer is NULL). In this article, we will show ... Read More

30K+ Views
In C++, arranging the elements in increasing or decreasing order is called as Sorting. we usually use the sort() function from the STL (Standard Template Library). A sorted array is an array whose each of the elements are sorted in some order such as numerical, alphabetical etc. There are many algorithms to sort a numerical array like bubble sort, insertion sort, selection sort, merge sort, quick sort, heap sort, etc. The selection sort is a sorting method that yields a sorted array. It does so by repeatedly finding the smallest element in the array and interchanging it with the element ... Read More

19K+ Views
The binary search algorithm works as per the divide-and-conquer principle, as it keeps dividing the array in half before searching. To search for an element in an array using binary search, it should be sorted. In the sorted array, we find the middle element and compare it with the element that has to be searched, and based on the comparison, we either search in the left or right sub-array or return the middle element. In this article, we are given a sorted array of integers, and our task is to search for the given target element using the binary search ... Read More

10K+ Views
Constructors are functions of a class that are executed when new objects of the class are created. The constructors have the same name as the class and no return type, not even void. They are primarily useful for providing initial values for variables of the class.The two main types of constructors are default constructors and parameterized constructors. Details about these are given as follows.Default ConstructorsDefault constructors do not take any parameters. If a default constructor is not provided by the programmer explicitly, then the compiler provides a implicit default constructor. In that case, the default values of the variables are ... Read More