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

144 Views
In this problem, we are given a number N. Our task is to create a program to find N-th term of series 1, 2, 11, 12, 21… in C++.Problem DescriptionTo find the Nth term of the series −1, 2, 11, 12, 21, 22, 111, 112, .... NtermsWe will find the general term of the series.Let’s take an example to understand the problem, InputN = 8Output112Solution ApproachTo derive the general term, we need to closely observe the series. In this series, we can see that there are only 1’s and 2’s in the value. And every term is an alternation of ... Read More

225 Views
In this problem, we are given the length (L) and speed (S) of the train along with the time taken by it to pass the bridge. Our task is to create a program to find Length of Bridge using Speed and Length of Train in C++.Problem DescriptionWe need to find the length of the bride using the speed of the train, the time taken by it to cross the bridge, And the length of the train.Let’s take an example to understand the problem, Input: L = 310, S = 45m/sec , time = 12 secOutput: 230 mSolution ApproachThe whole train ... Read More

610 Views
In this problem, we are given a number N. Our task is to create a Program to find last two digits of Nth Fibonacci number in C++.Problem DescriptionWe need to find the last two digits (i.e. the two LSB’s ) of the Nth Fibonacci number. Let’s take an example to understand the problem, Input: N = 120 Output: 81Solution ApproachA simple solution will be using the direct Fibonacci formula to find the Nth term. But this method will not be feasible when N is a large number. So to overcome this, we will use the property of the Fibonacci Series that ... Read More

200 Views
In this problem, we are given two numbers N and M. Our task is to create a program to find LCM of two Fibonacci Numbers in C++.Problem Description − We will find the Nth and Mth Fibonacci number. And then we will find the LCM of their two numbers and return the result.Fibonacci Numbers0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377....Let’s take an example to understand the problem, Input: N = 4, B = 9Output:Explanation4th Fibonacci number is 29th Fibonacci number is 21LCM is 42.Solution ApproachTo solve the problem, we need to find ... Read More

619 Views
In this problem, we are given a number N. Our task is to create a Program to find last two digits of 2^n in C++.Problem DescriptionTo find the last two digits. We will use only the product of the last two digits. And leave other things to make the calculation small.Let’s take an example to understand the problem, Input: N = 12 Output: 96Explanation2^12 = 4096Solution ApproachTo solve the problem, a direct approach could be finding the value of 2^N and then finding the remainder when it is divided by 100.Example Live Demo#include using namespace std; int findLastDigit(int N){ int ... Read More

576 Views
In this problem, we are given a number N. Our task is to create a Program to find last digit of Nth Fibonacci number in C++.Problem DescriptionWe need to find the last digit (i.e. LSB ) of the Nth Fibonacci number.Let’s take an example to understand the problem, Input: N = 120 Output: 1Solution ApproachA simple solution will be using the direct Fibonacci formula to find the Nth term. But this method will not be feasible when N is a large number. So to overcome this thing, we will use the property of the Fibonacci Series that the last digit ... Read More

485 Views
In this tutorial, we will be discussing a program to find the largest element in an array.For this, we will be provided with an array. Our task is to find the largest number from the elements inside the array.Example Live Demo#include using namespace std; //finding largest integer int largest(int arr[], int n){ int i; int max = arr[0]; //traversing other elements for (i = 1; i < n; i++) if (arr[i] > max) max = arr[i]; return max; } int main(){ int arr[] = {10, 324, 45, 90, 9808}; int n = sizeof(arr) / sizeof(arr[0]); cout

246 Views
In this tutorial, we will be discussing a program to find if a character is a vowel or consonant.For this, we will be provided with a character. Our task is to print out to the user whether the provided character is a vowel or a consonant.Example Live Demo#include using namespace std; //checking if the character is a vowel or consonant void is_vowel(char x){ if (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u') cout

249 Views
In this tutorial, we will be discussing a program to find HCF iteratively.For this, we will be provided with two numbers. Our task is to calculate the HCF of the given numbers using an iterative function.Example Live Demo#include using namespace std; int get_HCF(int a, int b){ while (a != b){ if (a > b) a = a - b; else b = b - a; } return a; } int main(){ int a = 60, b = 96; cout

148 Views
In this tutorial, we will be discussing a program to find N-th term of series 3, 5, 33, 35, 53…For this, we will be provided with a number. Our task is to find the term for the given series at that particular position.Example Live Demo#include using namespace std; //finding the nth term in the series int printNthElement(int n){ int arr[n + 1]; arr[1] = 3; arr[2] = 5; for (int i = 3; i