- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 35164 Articles for Programming
5K+ Views
The queue which is implemented as FIFO where insertions are done at one end (rear) and deletions are done from another end (front). The first element that entered is deleted first.Queue operations areEnQueue (int data): Insertion at rear endint DeQueue(): Deletion from front endBut a priority queue doesn’t follow First-In-First-Out, but rather than each element has a priority based on the basis of urgency.Items with the same priority are processed on First-In-First-Out service basis.An item with higher priority is processed before other items with lower priority.Class DescriptionsBegin class Priority_Queue has following functions: function insert() to insert items at ... Read More
22K+ Views
A queue is an abstract 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.A circular queue is a type of queue in which the last position is connected to the first position to make a circle.A program to implement circular queue in C++ is given as follows −Example#include using namespace std; int cqueue[5]; int front = -1, rear = -1, n=5; void insertCQ(int val) { if ((front == 0 && rear == n-1) || (front == rear+1)) { cout
2K+ Views
Pure functions always return the same result for the same argument values. They only return the result and there are no extra side effects like argument modification, I/O stream, output generation etc.Some pure functions are sin(), strlen(), sqrt(), max(), pow(), floor() etc. Some impure functions are rand(), time() etc.Some programs to demonstrate some of the pure functions are as follows −strlen()The strlen() function is used to find the length of a string. This is demonstrated in the following program −Example Live Demo#include #include using namespace std; int main() { char str[] = "Rainbows are beautiful"; int count = ... Read More
76 Views
The iscntrl() function in C++ checks if a character is a control character or not. This function is defined in ctype.h.The syntax for iscntrl() function is given as follows −int iscntrl ( int ch );Here, ch is the character that needs to be checked.A program that demonstrates iscntrl() function by counting the number of control characters in a string is given as follows −Example Live Demo#include #include using namespace std; int main() { char str[] = "Coding\tis\tfun"; int i, count = 0; for(i=0; str[i]!='\0';i++) { if(iscntrl(str[i])) count++; } cout
1K+ Views
There are two time periods provided in the form of hours, minutes and seconds. Then their difference is calculated. For example −Time period 1 = 8:6:2 Time period 2 = 3:9:3 Time Difference is 4:56:59A program that calculates the difference between two time periods is given as follows −Example Live Demo#include using namespace std; int main() { int hour1, minute1, second1; int hour2, minute2, second2; int diff_hour, diff_minute, diff_second; cout minute1 >> second1; cout minute2 >> second2; if(second2 > second1) { minute1--; second1 ... Read More
918 Views
Three numbers can be swapped in cyclic order by passing them to a function cyclicSwapping() using call by reference. This function swaps the numbers in a cyclic fashion.The program to swap numbers in cyclic order using call by reference is given as follows −Example Live Demo#include using namespace std; void cyclicSwapping(int *x, int *y, int *z) { int temp; temp = *y; *y = *x; *x = *z; *z = temp; } int main() { int x, y, z; cout > y >> z; cout
19K+ Views
Static data members are class members that are declared using the static keyword. There is only one copy of the static data member in the class, even if there are many class objects. This is because all the objects share the static data member. The static data member is always initialized to zero when the first class object is created.The syntax of the static data members is given as follows −static data_type data_member_name;In the above syntax, static keyword is used. The data_type is the C++ data type such as int, float etc. The data_member_name is the name provided to the ... Read More
3K+ Views
The isspace() function is a predefined function in ctype.h. It specifies whether the argument is a whitespace character or not. Some of the whitespace characters are space, horizontal tab, vertical tab etc.A program that implements isspace() function by counting the number of spaces in a string is given as follows −Example Live Demo#include #include using namespace std; int main() { char str[] = "Coding is fun"; int i, count = 0; for(i=0; str[i]!='\0';i++) { if(isspace(str[i])) count++; } cout
5K+ Views
Multiple inheritance occurs when a class inherits from more than one base class. So the class can inherit features from multiple base classes using multiple inheritance. This is an important feature of object oriented programming languages such as C++.A diagram that demonstrates multiple inheritance is given below −A program to implement multiple inheritance in C++ is given as follows −Example Live Demo#include using namespace std; class A { public: int a = 5; A() { cout
1K+ Views
The strstr() function is a predefined function in string.h. It is used to find the occurance of a substring in a string. This process of matching stops at ‘\0’ and does not include it.Syntax of strstr() is as follows −char *strstr( const char *str1, const char *str2)In the above syntax, strstr() finds the first occurance of string str2 in the string str1. A program that implements strstr() is as follows −Example Live Demo#include #include using namespace std; int main() { char str1[] = "Apples are red"; char str2[] = "are"; char *ptr; ptr = strstr(str1, str2); if(ptr) cout