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
 
C++ Articles - Page 361 of 719
 
			
			236 Views
Suppose we have a string s that is containing lowercase letters and an integer k. We have to maintain some properties. These are −First, we have to change some characters (if needed) of s to other lowercase English letters.Then divide the string s into k substrings such that each substring is a palindrome.We have to find the minimal number of characters that we need to change to divide the string.So if the string is like “ababbc” and k = 2, then the answer will be 1, as we have to change one character to split this into two palindrome strings. ... Read More
 
			
			671 Views
In this problem, we are given a number n that denotes that side of the pentagon. Our task is to create a program to find the Area of a Pentagon in C++.Pentagon is a five-sided geometric figure.Regular pentagon is a pentagon with all five sides and angles equal.Let’s take an example to understand the problem,Inputa = 7Output84.3Program to illustrate the working of our solution,Example Live Demo#include using namespace std; float calcpentagonArea(int a){ return ( ((6.8819)*a*a)/4); } int main() { int a = 7; cout
 
			
			1K+ Views
Suppose we have a car, that starts at position 0 and speed +1 on an infinite number line. The car runs automatically according to a sequence of instructions A: for accelerate and R − for reverse. When we get an instruction "A", our car does the following −position := position + speed, then speed = speed * 2.When we get an instruction "R", our car does the following −if speed is positive then speed = -1, otherwise speed = 1.For example, after executing the instructions "AAR", our car goes to positions 0->1->3->3, and speed goes to 1->2->4->-1.Now suppose we have ... Read More
 
			
			450 Views
In this problem, we are given two values that denote the base and height of a parallelogram. Our task is to create a Program to find the Area of a Parallelogram in C++.Parallelogram is a four side closed figure that has opposite sides equal and parallel to each other.Let’s take an example to understand the problem, InputB = 20, H = 15Output300ExplanationArea of parallelogram = B * H = 20 * 15 = 300Solution ApproachTo solve the problem, we will use the geometrical formula for area of parallelogram, Area = base * height.Program to illustrate the working of our solution, ... Read More
 
			
			1K+ Views
Suppose we have a list of bus routes. In each routes[i] there is a bus route that the i-th bus repeats forever. So, if routes[0] = [1, 5, 7], this means that the first bus (0-th indexed) travels in the sequence 1, 5, 7, 1, 5, 7, 1, ... forever.Now suppose we start at bus stop S, initially not on a bus, and we want to go to bus stop T. we have to find the least number of buses we must take to reach our destination? If this is not possible then return -1.So if the input is like ... Read More
 
			
			227 Views
In this tutorial, we will be discussing a program to find the area of an Ellipse.For this, we will be provided with the semi-major axis and semi-minor axis of the Ellipse. Our task is to calculate and print out the area of the given Ellipse.Example Live Demo#include using namespace std; //finding area of ellipse void findArea( float a, float b) { float Area; Area = 3.142 * a * b ; cout
 
			
			310 Views
Suppose we have an array called nums, where nums[i] are written on a chalkboard. Ram and Sam take turns erasing exactly one element from the chalkboard, with Ram starting first. If erasing a number causes the bitwise XOR of all the elements of the chalkboard to become 0, then that player loses. Bitwise XOR of one element is that element itself, and the bitwise XOR of no elements is 0. If any player starts their turn with the bitwise XOR of all the elements of the chalkboard equal to 0, then that player will win. Suppose the array is holding ... Read More
 
			
			227 Views
In this problem, we are given a value that denotes the side of an icosahedron. Our task is to create a program to find the Area and Volume of Icosahedron in C++.Icosahedron is a regular 30 sided polyhedron. It has 20 equilateral triangles of the same side. There are only 12 vertices of this polyhedron.Dashed lines are for the edges that are behind the visible surface.Let’s take an example to understand the problem, Inputa = 4Program to illustrate the working of our solution, Example Live Demo#include using namespace std; float calcIcoSArea(float a) { return (8.660 * a * a); ... Read More
 
			
			390 Views
Suppose we have one array A, we must move every element of A to either list B or list C. (These lists B and C are initially empty.) We have to check whether after such a move, it is possible that the average value of B is equal to the average value of C, and B and C are both non-empty.So if the input is like − [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], then the result will be true, To solve this, we will follow these steps −n := size of A, total := 0for initialize ... Read More
 
			
			336 Views
In this problem, we are given a value that denotes the radius of a semicircle. Our task is to create a program to find the Area and Perimeter of a Semicircle in C++.SemiCircle is a closed figure that is half of a circle.Let’s take an example to understand the problem, InputR = 5Outputarea = 39.25 perimeter = 15.7Solution ApproachTo solve the problem, we will use the mathematical formula for the area and perimeter of a semi-circle which is derived by dividing the area of circle by 2.Area of semicircle, A= $½(\prod^*a^2)=1.571^*a^2$Perimeter of semicircle, P =(π*a)Area of semicircle, area = $½(π^*a^2)$Program ... Read More