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

168 Views
We are given with the stick of any length and that stick can be broken randomly into n pieces which can be of type integer or floating point and the task is to find whether the broken pieces can form a n sided polygon.We can calculate the probability by applying the formula$$P(E^{\prime})=1-P(E)=1-\frac{n}{2^{n-1}}$$Where, n is the number of pieces generated by breaking the stick into parts.Input length = 10 , pieces = 4Output probability is : 0.5Explanation − given with length of size 10 cm and it is broken into 4 partsInput length = 5 , pieces = 3Output probability is : 0.25Explanation − given ... Read More

313 Views
A person “A” is walking from a starting position X = 0, the task is to find the probability to reach exactly X = num, if he/she can either take 2 or 3 steps. Probability for step length 2 i.e. P, the probability for the step length 3 is 1 - P.Input num = 5, p = 0.2Output 0.32Explanation There can be 2 ways to reach num, i.e, 5 2+3 with probability 0.2 * 0.8 = 0.16 3+2 with probability 0.8 * 0.2 = 0.16 So, total probability will be 0.16 + 0.16 = 0.32Input num = 2, p = 0.1Output 0.1Approach used below is ... Read More

195 Views
Given with an array containing 0’s and 1’s where 0’s represents no rain and 1’s represent rainy day. The task is to calculate the probability of rain on N+1th day.To calculate the probability of rain on N+1th day we can apply the formulaTotal number of rainy days in the set / total number of days in aInput arr[] = {1, 0, 0, 0, 1 }Output probability of rain on n+1th day : 0.4Explanation total number of rainy and non-rainy days are: 5 Total number of rainy days represented by 1 are: 2 Probability of rain on N+1th day is: 2 / 5 = ... Read More

122 Views
Given three players A, B, C throwing dice, we have to find the probability of the C throwing the dice and the number scored by C is higher than both A and B.To check the probability of getting more value, we have to keep in mind that the value of the third dice throw is higher than the previous two.Like A thrown the dice and score 2 and B thrown the dice and scored 3 so the probability of C getting higher value is 3/6 = 1/2, because there are only 3 values which can be higher than the A ... Read More

1K+ Views
Given with an array of natural numbers and one more array containing the weights of the corresponding natural numbers and the task is to calculate the weighted mean of natural numbers.There is a formula which is used for calculating the weighted mean of natural numbers.$$\overline{x}=\frac{\displaystyle\sum\limits_{i=1}^n (x_{i*}w_{i})}{\displaystyle\sum\limits_{i=1}^n w_{i}}$$Where, x is the natural number and w is the weighted associated with that natural number.Input X[] = {11, 22, 43, 34, 25, 16} W[] = {12, 12, 43, 54, 75, 16}Output weighted mean is : 29.3019Explanation (11*12 + 22*12 + 43*43 + 34*54 + 25*75 + 16*16) / (12 + 12 + 43 + 54 +75 ... Read More

243 Views
Given with the radius and height of cylindrical water tank, ‘n’ number of spherical solid balls with the radius and the volume of water in the tank and the task is to check whether the tank will overflow or not when balls are dipped in the tank.Formula to calculate the volumeCylinder 3.14 * r * r * hWhere, r is radius of tank and h is the height of the tankSphere (4/3) * 3.14 * R * R * RWhere, R is radius of sphere ballInput tank_height = 5 tank_radius = 2 water_volume = 10 capacity = 10 ball_radius = 2Output It will overflowApproach ... Read More

2K+ Views
Given an array arr[n] of n integers, the task is to find whether array is a palindrome or not. We have to do the stated task using STL in C++.In C++ there is a feature of STL(Standard Template Library), it is a set of C++ template classes which are used to provide the data structures and several functions such as stacks, queues, lists, etc. To use these one must have knowledge of template classes.Palindrome is a sequence which is read the same from the front or rear of the sequence. Some simple examples of a palindrome are − MADAM, RACECAR, ... Read More

3K+ Views
Given coordinates of three points in 2D plane, and the task is to check whether the points are collinear or not. For Example, // Input: Coordinates of three points points = {{2, 3}, {4, 6}, {6, 9}}; // Output The points are collinear. What are Collinear Points? Points are said to be collinear if they lie on the same line and they are not collinear if they are on the different lines. Given below is the figure of collinear and non-collinear points. Checking Collinearity with Area of Triangle To form a triangle, we ... Read More

1K+ Views
Given with a number ‘n’ and the task is to determine whether the given positive integer is a buzz number or not and display the result as an output.What is Buzz Number?For being a buzz number there are two conditions either of which must be true −Number should end with digit 7 e.g. 27, 657, etc.Number should be divisible by 7 e.g 63, 49, etc.Inputnumber: 49Outputit’s a buzz numberExplanation − since the number is divisible by 7 so it’s a buzz numberInputnumber: 29Outputit’s not a buzz numberExplanation − since the number is neither divisible by 7 nor end with digit ... Read More

853 Views
Given with a number ‘n’ and the task is to determine whether the given positive integer is a proth or not and display the result as an output.What is Proth Number?A proth number is given by$$N=k\cdot\:2^{n}+1$$Where, n is a positive integer and k is a odd positive integerThe first few proth numbers are given below −3, 5, 9, 13, 17, 25, 33, 41, 49, 57, 65, 81, 97.......Inputnumber: 17Outputits a proth numberInputnumber: 18Outputits not a proth numberApproach used in the given program is as followsInput the number to check for the conditionApply the given formula to check whether its a ... Read More