- Trending Categories
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 7347 Articles for C++
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
136 Views
Here we will see how to print the matrix elements in Z form. So if the array is like below −5 8 7 1 2 3 6 4 1 7 8 9 4 8 1 5Then it will be printed like: 5, 8, 7, 1, 6, 7, 4, 8, 1, 5AlgorithmprintMatrixZ(mat)Begin print the first row i := 1, j := n-2 while i < n and j >= 0, do print mat[i, j] i := i + 1, j := j - 1 done print the last row EndExample#include #define MAX 4 using namespace std; void printMatrixZ(int mat[][MAX], int n){ for(int i = 0; i
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
175 Views
Here we will see how to check whether the given sum is found by adding some nonneighbouring Fibonacci numbers or not, if so, what are the numbers? For example if the give sum value is 10, this is sum of 8 and 2. Both 8 and 2 are Fibonacci terms and they are not adjacent. Let us see the algorithm to get the idea.AlgorithmnonNeighbourFibo(sum)Begin while sum > 0, do fibo := greatest Fibonacci term but not greater than sum print fibo sum := sum - fibo done EndExample#include using ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
178 Views
Here we will see another sorting algorithm called the Bogo Sort. This sort is also known as Permutation sort, Stupid sort, slow sort etc. This sorting algorithm is particularly ineffective sorting technique. This comes under the generate and test paradigm. It repeatedly generates a permutation until it is sorted. The conception is very straight forward. Until the list is sorted just shuffle the elements.AlgorithmbogoSort(array, n)Begin while the arr is not sorted, do shuffle arr done EndExample#include #include using namespace std; bool isSorted(int arr[], int n) { //check whether the list is sorted or not ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
161 Views
Here we will see the Class internals. Before that we will see Default constructors, which are related to internals. The default constructor is one constructor (defined by user or compiler) that does not take any argument. Now the question comes, why the default constructor is used?If the default constructor is not given, the compiler will implicitly declare default constructor. Default constructors are used to initialize some class internals. It will not affect the data member of the class. The compiler inserts default constructor in some different situations. Suppose a class is derived from another class with default constructor, or one ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
11K+ Views
There are different ways by which system day, date and time can be printed in Human Readable Form.First wayUsing time() − It is used to find the current calendar time and have arithmetic data type that store timelocaltime() − It is used to fill the structure with date and timeasctime() − It converts Local time into Human Readable FormatDay Month Date hour:month:second YearExample#include #include // used to work with date and time using namespace std; int main() { time_t t; // t passed as argument in function time() struct tm * tt; // decalring variable for localtime() ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
285 Views
Here we will see how to get the median of two sorted array of the same size. We will use C++ STL to store array elements. After getting two arrays, we will merge them into one. As two arrays of same size are merged, then the final array will always hold even number of elements. We need to take two middle elements, then get the average of them for the median.Algorithmmedian(arr1, arr2)Begin arr3 := array after merging arr1 and arr2 sort arr3 len := length of arr3 mid := len/2 median := (arr3[mid] + arr3[mid-1])/2 ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
131 Views
Here we will see one program that will help to check whether a matrix is bisymmetric or not. The Bisymmetric matrix is one square matrix that are symmetric about both of the major diagonals. The below matrix is an example of bisymmetric matrix.1 2 3 4 5 2 6 7 8 4 3 7 9 7 3 4 8 7 6 2 5 4 3 2 1AlgorithmcheckBiSymmetric(mat, n)Begin for i in range 0 to n – 1, do for j in range 0 to i – 1, do if mat[i, j] is ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
361 Views
In this section we will see what are the usage of array::fill() and the array::swap() in C++ STL.The array::fill() function is used to fill the array with some specified value. Let us see one example to get the idea.Example Live Demo#include #include using namespace std; main() { array arr = {00, 11, 22, 33, 44, 55, 66, 77, 88, 99}; cout
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
69 Views
Here we will see the crbegin() and crend() functions of array in C++ STL.The array::crbegin() function is used to get reverse iterator. It returns constant reverse iterator pointing to the last element of the container. This function does not take any parameter.The array::crend() function is reverse of crbegin(). This returns the iterator which is pointing the last element of the reversed iterator.Let us see some code examples to get better idea.Example Live Demo#include #include using namespace std; main() { array arr = {00, 11, 22, 33, 44, 55, 66, 77, 88, 99}; cout