 
 Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP 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 90 of 134
 
 
			
			2K+ Views
The sum of squares of the first n even numbers means that, we first find the square and add all them to give the sum.There are two methods to find the sum of squares of the first n even numberUsing LoopsWe can use loops to iterate from 1 to n increase number by 1 each time find the square and add it to the sum variable −Example#include using namespace std; int main() { int sum = 0, n =12; for (int i = 1; i
 
 
			
			1K+ Views
C programming puzzles are small but tricky coding problems, which are designed to challenge and to understand the C programming language in a better way. Problem Statement We are given two numbers, and our task is to combine them in such a way that the second integer is placed before the first integer, resulting in a single combined integer. But here, we are not allowed to use any logical, arithmetic, string-related operations, or any pre-defined functions. Consider the following input/output scenarios to understand the puzzle statement better: Scenario 1 Input: 12, 54 Output: 5412 Explanation: Here, the second ... Read More
 
 
			
			262 Views
This an array based puzzle that need you to change all the numbers of an array the contains two elements to 0. One element of the array is 0 and other may or may not be 0.To solve this puzzle the program needs to find the non-zero element and change in to 0.Their are the following constraints that are needed to solve the boolean array puzzle −Allowed operation is complement, other operations are not allowed.Loops and conditional statements are not allowed.Direct assignment is also not allowed.PROGRAM TO SOLVE BOOLEAN ARRAY PUZZLE#include using namespace std; void makeZero(int a[2]) { a[ ... Read More
 
 
			
			3K+ Views
An abundant Number (also known as excessive number) is a number in the number theory which itself is smaller than the sum of all its proper divisors. For example, 12 is an abundant Number : divisors 1, 2, 3, 4, 6 , sum =16 >12.The difference between the sum of divisors and the number is called abundance. For above example abundance = 4 => 16 - 12 .To check for abundant number we will find all the factors of the number and add them up. This sum compared with the number show that if the number is abundant or not.PROGRAM ... Read More
 
 
			
			179 Views
An array stores number of same data type. For an array there may arise a situation when you need to store 2-3 values that are same i.e. 3,3,3,3 needs to be stored.For this case, the programing language C has made a simple way to create an array with such repeated value to reduce the workload of the programmer.Syntax[startofRepeatingSeq … EndofRepeatingSeq]number Example : For 3 repeated 5 times ; [0 … 4]3Example#include int main() { int array[10] = {[0 ... 4]3, [6 ... 9]5}; for (int i = 0; i < 10; i++) printf("%d ", array[i]); return 0; }Output3 3 3 3 3 0 5 5 5 5
 
 
			
			693 Views
Modified game of Nim is an optimisation games of arrays. This game predicts the winner based on the starting player and optimal moves.Game Logic − In this game, we are given an array{}, that contains elements. There are generally two players that play the game namly player1 and player2. The aim of both is to make sure that all their numbers are removed from the array. Now, player1 has to remove all the numbers that are divisible by 3 and the player2 has to remove all the numbers that are divisible by 5. The aim is to make sure that ... Read More
 
 
			
			408 Views
A binary tree is a tree data structure in which there are two child nodes for each node. The child nodes being two are referred as, left and right child.A BST is a tree structure in which left subtree contains nodes with values lesser than root and right subtree contains nodes with values greater that root.Here, we will check if a binary tree is a BST or not −To check for this we have to check for the BST condition on the binary tree. For a root node check for left child should be less that root, right child should ... Read More
 
 
			
			26K+ Views
A knapsack is a bag. And the knapsack problem deals with the putting items to the bag based on the value of the items. It aim is to maximise the value inside the bag. In 0-1 Knapsack you can either put the item or discard it, there is no concept of putting some part of item in the knapsack.Sample ProblemValue of items = {20, 25, 40} Weights of items = {25, 20, 30} Capacity of the bag = 50Weight distribution25, 20{1, 2} 20, 30 {2, 3} If we use {1, 3} the weight will be above the max allowed value. ... Read More
 
 
			
			125 Views
The bitonicity of an array is defined using the following syntax −To find bitonicity of an array based on its elements is −Bitonicity = 0 , initially arr[0] i from 0 to n Bitonicity = Bitonicity+1 ; if arr[i] > arr[i-1] Bitonicity = Bitonicity-1 ; if arr[i] < arr[i-1] Bitonicity = Bitonicity ; if arr[i] = arr[i-1]ExampleThe code for finding the bitonicity of an array we have used a variable called bitonicity, that changes its based on the comparison of the current and previous elements of the array. The above logic updates the bitonicity of the array and final bitonicity ... Read More
 
 
			
			181 Views
A tetrahedron is a pyramid with triangular base i.e. it has a base that is a triangle and each side has a triangle. All the three triangles converge to a point. As in the figure, Area of Tetrahedron = (√3)a2ExampleThe code to find the area of tetrahedron uses the math library to find the square and square-root of a number using sqrt and pow methods. For calculating the area we take a floating point and the value of the expression "((sqrt(3)*a*a))" is given to it.#include #include int main() { int a= 5; float area, volume; ... Read More