
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 1339 Articles for C

400 Views
To check whether a number is divisible by 3, we add all the digits of the number and then calculate that the sum is divisible by 3 or not. In this problem, there is an array of integers arr[], and we have to check if a number formed with these number is divisible by 3. If the number formed is divisible then print ‘yes’ else print ‘no’Input: arr[] = {45, 51, 90} Output: YesExplanationconstruct a number which is divisible by 3, for example, 945510.So the answer will be Yes Find the remainder of the sum when divided by 3 true ... Read More

220 Views
A triangle that is made by using matchsticks arrange to make an equilateral triangle, this is called the triangular matchstick number. Triangular matchstick number is the number of matchsticks required to make the matchstick triangle.In this problem, we have the number is the floor of a matchstick pyramid, X. and our task is to write a program to print the total minimum number of matchstick required to form a pyramid of matchsticks of x floors.Let's look at an example that will make the concept more clear, Input: 7 Output: 84ExplanationThis is an extension of triangular numbers. For integer X, the ... Read More

493 Views
The odd-even sword also known as the brick sort is a similar sorting technique, like bubble sort. This sorting technique is subdivided into 2 phases odd phase and even phase, Both these phases simultaneously at every iteration until all the elements get sorted.The Odd phase of this programming technique works as a bubble sort but only on the elements that have an odd index.Similarly, the even phase works only on the elements that have an even index.For making this concept more clear let's take an example :Input: a[]={3, 5, 7, 6, 1, 4, 2} Output: 1 2 3 4 5 ... Read More

139 Views
We have an n number of coins and we have to French the coin way that it makeup Pyramid of maximum height. We will arrange the first coin in First row second and third coin in the second row and so onIn the given diagram, we make pyramid 6 of coins having a height of 3. We cannot make height 4 but we will need 10 coins. It is simple to get the height by using this formula;H = {(-1+ √(1+8N))/2}Input: n = 10 Output: Height of pyramid: 4ExplanationHeight by using this formulaH = {(-1+ √(1+8N))/2}Example#include #include using ... Read More

397 Views
A set of points on a plain surface that forms a curve such that any point on that curve is equidistant from a point in the center (called focus) is a parabola.The general equation for the parabola isy = ax2 + bx + cThe vertex of a parabola is the coordinate from which it takes the sharpest turn whereas a is the straight-line used to generate the curve.Focus is the point with is equidistant from all points of the parabola.Here, we will find the vertex, focus, and directrix of a parabola. There is a mathematical formula that finds all these ... Read More

272 Views
There are n number of elements stored in an array and this program calculates the average of those numbers. Using different methods.Input - 1 2 3 4 5 6 7Output - 4Explanation - Sum of elements of array 1+2+3+4+5+6+7=28No of element in array=7Average=28/7=4There are two methodsMethod 1 −IterativeIn this method we will find sum and divide the sum by the total number of elements.Given array arr[] and size of array nInput - 1 2 3 4 5 6 7Output - 4Explanation - Sum of elements of array 1+2+3+4+5+6+7=28No of element in array=7Average=28/7=4Example#include using namespace std; int main() { int arr[] = { 1, 2, 3, ... Read More

226 Views
Given an array, add the minimum number (which should be greater than 0) to the array so that the sum of array becomes even.Input - 1 2 3 4, Output - 2Explanation - Sum of array is 10, so we add minimum number 2 to make the sum even.Method 1: calculate the sum of all elements of the array, then check if the sum is even then add minimum number is 2, else add minimum number is 1.Input - 1 2 3 4, Output - 2Explanation - Sum of array is 10, so we add minimum number 2 to make the sum even.Example#include using namespace std; int ... Read More

3K+ Views
Arithmetic mean is the sum of a collection of numbers divided by the number of numbers in the collection.Basic properties of Arithmetic MeanThe mean of n numbers x1, x2, . . ., xn is x. If each observation is increased by p, the mean of the new observations is (x + p).The mean of n numbers x1, x2, . . ., xn is x. If each observation is decreased by p, the mean of the new observations is (x - p).The mean of n numbers x1, x2, . . ., xn is x. If each observation is multiplied by a nonzero ... Read More

13K+ Views
The tower of Hanoi is a mathematical puzzle. It consists of three rods and a number of disks of different sizes which can slide onto any rod. The puzzle starts with the disks in a neat stack in ascending order of size on one rod, the smallest at the top. We have to obtain the same stack on the third rod.The objective of the puzzle is to move the entire stack to another rod, obeying the following simple rules−Only one disk can be moved at a time.Each move consists of taking the upper disk from one of the stacks and ... Read More

599 Views
Catalan numbers are a sequence of numbers. Catalan numbers form a sequence of natural numbers that occur in various counting problems, often involving recursively-defined objects.Cn is the number of Dyck words of length 2n. A Dyck word is a string consisting of n X's and n Y's such that no initial segment of the string has more Y's than X's. For example, the following are the Dyck words of length 6XXXYYY XYXXYY XYXYXY XXYYXY XXYXYY.Re-interpreting the symbol X as an open parenthesis and Y as a close parenthesis, Cn counts the number of expressions containing n pairs of parentheses which ... Read More