
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

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

91K+ 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

28K+ Views
A nested class is a class that is declared in another class. The nested class is also a member variable of the enclosing class and has the same access rights as the other members. However, the member functions of the enclosing class have no special access to the members of a nested class. Syntax Here is the basic syntax defining and using nested classes in C++. class OuterClass { // Members of the outer classpublic: // Nested class definition class InnerClass { // Members of the inner class };}; Accessing Nested Classes To access a nested class from outside ... Read More

3K+ Views
A class declared inside a function is known as a local class in C++ as it is local to that function, where its scope is limited to that function. Syntax Here the syntax for a local class is given as follows. #include using namespace std; void func() { class LocalClass { }; } int main() { return 0; } In the above syntax, func() is a function, and class LocalClass is defined inside the function. So, it is known as a local class. A local class name can only be used in its function and not outside it. Also, the ... Read More