- 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++
![Hafeezul Kareem](https://www.tutorialspoint.com/assets/profiles/120468/profile/60_159160-1581501828.jpg)
178 Views
In this tutorial, we are going to write a program that finds out the smallest element after removing some integers from the natural numbers.We have given an array of elements and k value. Remove all the elements from natural numbers that are present in the given array. And then find the k-th smallest number from the remaining natural numbers.Let's see the steps to solve the problem.Initialise the array and k.Initialise an array and initialise all the elements with 0 except the elements present in the given array.Write a loop that iterates till the size of the given array.Decrement the value ... Read More
![Hafeezul Kareem](https://www.tutorialspoint.com/assets/profiles/120468/profile/60_159160-1581501828.jpg)
227 Views
In this tutorial, we are going to write a program that finds out the k-th missing element in the given sorted array.Find the k-th number that is missing from min to max in the given unsorted array. Let's see the steps to solve the problem.Initialise the sorted array.Initialise two variables difference and count with k.Iterate over the array.If the current element is not equal to the next element.Find the difference between the two numbers.If the difference is greater than or equal to k, then return current element plus count.Else subtract difference from the count.Return -1.ExampleLet's see the code. Live Demo#include ... Read More
![Hafeezul Kareem](https://www.tutorialspoint.com/assets/profiles/120468/profile/60_159160-1581501828.jpg)
135 Views
In this tutorial, we are going to write a program that finds out the k-th missing element in the given unsorted array.Find the k-th number that is missing from min to max in the given unsorted array. Let's see the steps to solve the problem.Initialise the unsorted array.Insert all the elements into a set.Find the max and min elements from the array.Write a loop that iterates from min to max and maintain a variable for the count.If the current element is present in the set, then increment the count.If the count is equal to k, then return i.ExampleLet's see the ... Read More
![Hafeezul Kareem](https://www.tutorialspoint.com/assets/profiles/120468/profile/60_159160-1581501828.jpg)
1K+ Views
In this tutorial, we are going to write a program that finds the k-th largest element from the max-heap.We will use priority queue to solve the problem. Let's see the steps to complete the program.Initialise the max-heap with correct values.Create a priority queue and insert the root node of the max-heap.Write a loop that iterates k - 1 times.Pop the greatest element from the queue.Add the left and right nodes of the above node into the priority queue.The greatest element in priority queue is the k-th greatest element now.Return it.ExampleLet's see the code. Live Demo#include using namespace std; struct Heap ... Read More
![Hafeezul Kareem](https://www.tutorialspoint.com/assets/profiles/120468/profile/60_159160-1581501828.jpg)
105 Views
In this tutorial, we are going to write a program that finds the k-th element from thee merged array of two sorted arrays.Let's see the steps to solve the problem.Initialise the two sorted arrays.Initialise an empty array of size m + n.Merge the two arrays into the new array.Return the k - 1 element from the merged array.ExampleLet's see the code. Live Demo#include using namespace std; int findKthElement(int arr_one[], int arr_two[], int m, int n, int k) { int sorted_arr[m + n]; int i = 0, j = 0, index = 0; while (i < m && ... Read More
![Hafeezul Kareem](https://www.tutorialspoint.com/assets/profiles/120468/profile/60_159160-1581501828.jpg)
250 Views
In this tutorial, we are going to write a program that finds the k-th digit from the right side in the number abIt's a straightforward problem. Let's see the steps to solve it.Initialise the numbers a, b, and k.Find the value of abusing pow method.Write a loop that iterates until power value is less than zero or count is less than k.Get the last digit from the power value.Increment the counter.Check whether k and counter are equal or not.Return the digit if they are equalReturn -1.ExampleLet's see the code. Live Demo#include using namespace std; int getTheDigit(int a, int b, int ... Read More
![Hafeezul Kareem](https://www.tutorialspoint.com/assets/profiles/120468/profile/60_159160-1581501828.jpg)
115 Views
In this tutorial, we are going to write a program that checks whether the given number is k-rough or k-jagged number or not.The number whose smallest prime factor is greater than or equal to the given k, it is called k-rough or k-jagged number.Let's see the steps to solve the problem.Initialise the numbers n and k.Find all the prime numbers that are factors of n and store them in a vector.Get the first element from the vector and compare it with k to check whether n is k-rough or k-jagged number or not.ExampleLet's see the code. Live Demo#include using namespace ... Read More
![Kiran Kumar Panigrahi](https://www.tutorialspoint.com/assets/profiles/390736/profile/60_2598-1635242143.png)
22K+ Views
In objectoriented programming, there are two important concepts of polymorphism namely, function overloading and function overriding. When two or more functions have the same name but their parameters are different, it is called function overloading. On the other hand, function overriding is one that provides a facility to redefine a function with a name and signature same as the inheriting class. Read this article to learn more about function overloading and overriding in C++ and how they are different from each other. What is Function Overloading? The concept by which we can define different function in a ... Read More
![Kiran Kumar Panigrahi](https://www.tutorialspoint.com/assets/profiles/390736/profile/60_2598-1635242143.png)
17K+ Views
The "&" and "&&" operators are both logical AND operators in most programming languages, but they can behave differently in certain circumstances. Both "&" and "&&" are operators used for evaluating conditional statements. The most basic difference between the two is that the "&" operator is a logical as well as a bitwise operator, whereas the "&&" operator is only a logical operator. Read this article to find out more about these two operators and how they are different from each other. Let's start with a basic overview of "&" and "&&" operators. What is "&" Operator? The & operator ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
766 Views
In this post, we will understand the difference between inline and macro in C++.InlineIt is a function in C++.It is parsed by the compiler.It can be defined inside or outside the class.It evaluates the argument only once.The compiler may not convert all functions to ‘inline’ function and expand them all.The short functions that are defined inside the class are automatically made as inline functions.An inline function inside a class can access the data members of the class.Inline function can be terminated using curly brackets.It is easy to debug.This is because error checking is done during compilation.It binds all statements in ... Read More