 
 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 46 of 134
 
 
			
			811 Views
We are given a right isosceles triangle. Isosceles triangle is the one which has two sides of equal length. Right triangle is the one which has height(ag in fig.) and base (dg in fig.) perpendicular to each other. The goal is to find the maximum number of squares that can fit into this right isosceles triangle of side 2 sq units. The sides base or height (both equal) are taken as input. No. of squares is output.Refer to the below figure to understand the problemThe given triangle of height ag and base gd has 3 squares of side 2 each. ... Read More
 
 
			
			469 Views
We are given an array of size N. The array has all 0’s initially. The task is to count the no. of 1’s in the array after N moves. Each Nth move has a rule associated. The rules are −1st Move − Change element at positions 1, 2, 3, 4…………..2nd Move − Change element at positions 2, 4, 6, 8…………..3rd Move − Change element at positions 3, 6, 9, 12…………..Count the number of 1’s in the last array.Let’s understand with examples.Input Arr[]={ 0, 0, 0, 0 } N=4Output Number of 1s in the array after N moves − 2Explanation − Array after ... Read More
 
 
			
			259 Views
We are given with a positive integer ‘N’. We have to find the maximum coefficient term in all binomial coefficients.The binomial coefficient series is nC0, nC1, nC2, …., nCr, …., nCn-2, nCn-1, nCnfind the maximum value of nCr.nCr = n! / r! * (n - r)!Input − N=4Output − Maximum Coefficient − 6Explanation − 4C0= 1, 4C1 = 4, 4C2 = 6, 4C3 = 4, 4C4 = 1Therefore, the maximum coefficient is 6 in this case.Input − N=5Output − Maximum Coefficient − 10Explanation − 5C0= 1, 5C1 = 5, 5C2 =10, 5C3 = 10, 5C4 = 5, 5C5 = 1Therefore, ... Read More
 
 
			
			275 Views
We are given with an array of positive and negative integers. The task is to find the maximum difference between positive and negative subsets of elements present in the array. As we have subsets of positive and negative numbers. Then the difference (sum of positives) - (sum of negatives) will always be maximum. This is because subtracting negatives will add them. Converting all negatives into positive and adding all the elements of the array will produce the desired result. Let us see examples for understanding −Input − Arr[] = { -2, 0, -3, 8, 10, 12, -4 }Output − Maximized ... Read More
 
 
			
			13K+ Views
We are given with an array of integers. The task is to find the minimum and maximum element of the array in the minimum number of comparisons.Input Arr[] = { 1, 2, 4, 5, -3, 91 }Output Maximum element : 91 Minimum Element : -3Explanation − Here to minimize the number of comparisons, we will initialize the maximum and minimum element with Arr[0]. And starting from the 2nd element compare each value with min and max and update accordingly.Input Arr[] = { 10, 20, 21, 31, 18, 11 }Output Maximum element : 31 Minimum Element : 10Explanation − Here also, to minimize the number ... Read More
 
 
			
			988 Views
We are given with an array of integers. The task is to calculate the maximum absolute difference of value and index sums. That is for each pair of indexes (i, j) in an array, we have to calculate | Arr[i] - A[j] | + |i-j| and find the maximum such sum possible. Here |A| means absolute value of A. If array has 4 elements then indexes are 0, 1, 2, 3 and unique pairs will be ( (0, 0), (1, 1), (2, 2), (3, 3), (0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3) ).Input − Arr[] ... Read More
 
 
			
			916 Views
There are multiple ways of declaring constants in C and C++. First of all, we need to understand what constant is.What is a Constant?Constant means which can’t be changed. In terms of programming, constants are the fixed values that are assigned to the variables such that they can’t be altered by any other variable or component during the execution of a program. Constants can be of any data type. They are used in the programming for defining the non-changing component of a program. There are some data or variables which have fixed value like Pi have fixed float value as ... Read More
 
 
			
			2K+ Views
We are given with an array of integers. The array has multiple occurrences of the same elements. The task here is to find the maximum distance between any two same elements of the array. We will pick each element from the array starting from the left. Then we will find the last occurrence of that same number and store the difference between indexes. Now if this difference is maximum then return it.Input Arr[] = { 1, 2, 4, 1, 3, 4, 2, 5, 6, 5 }Output −Maximum distance between two occurrences of same element in array − 4Explanation − The repeating ... Read More
 
 
			
			1K+ Views
We are given a string of alphabets. The array can have at least two occurrences of the same character. The task here is to find the maximum number of characters between any two occurrences of a character. If there is no repetition of any character then return -1.Input − string str = “abcdba”Output −Maximum number of characters between any two same character in a string − 4Explanation − The repeating characters are ‘a’ and ‘b’ only with indexes −1. 2‘a’ first index 0 last 5 , characters in between 5-0-1=4 2. ‘b’ first index 1 last 4 , characters in ... Read More