
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 33676 Articles for Programming

140 Views
According to the problem we are given a set arr[n] where n is the number of integer elements in the set, the task is to find the maximum difference elements which are to be added to obtain the elements in the set. In other words, the difference should be in form of |a-b| where 'a' and 'b' both are in the set and their difference should not be the least. So, we will count the maximum number of differences which are distinct and largest from a set. Let's understand the problem and its solution with help of an example.Input − ... Read More

726 Views
According to the problem we are given a string str, we must count all the substrings in the given string. Substring is a string which is a part of an already existing string whose size may be smaller than or equal to the existing string.Let's understand the problem and its solution with the help of examples.Input − str = "wxyz";Output − count of distinct substring is: 10Explanation − Distinct substrings counted are −wxyz, wxy, wx, w, xyz, xy, x, yz, y, z so their count is 10Input − str = "zzzz"Output − count of distinct substring is: 4Explanation − Distinct ... Read More

854 Views
The task is to find the greatest difference between the sum of m elements in an array. Suppose we have an array and a number m, then we will first find the sum of highest m numbers and then subtract the sum of lowest m numbers from it to get the maximum difference. So the main thing is to find two subsets of m numbers which have the highest sum and lowest sum.Let’s now understand what we have to do using an example −Input arr = {1, 2, 3, 4, 5} ; m=3Output Maximum difference here is : 6Explanation − Here the ... Read More

306 Views
We are given a matrix and the task is to find the greatest difference between the sum of elements in two rows of a matrix. Suppose we have a matrix M[i,j] with i rows and j columns. Let the rows be R0 to Ri-1. The difference will be calculated by subtracting the (sum of elements of Ry) - (sum of elements of Rx), where xMD. If it is so, update MD. Else check is RSum[row]

224 Views
We are given a positive integer N. The goal is to count the pairs of distinct non-negative positive integers that satisfy the inequality − x*x + y*y < N.We will start from x=0 to x2 lt; N and y=0 to y2 < N . If any x2 + y2 < N, increase count of pairs.Let us understand with examples −Input − n=4Output − distinct pairs= 4Explanation − pairs will be (0, 0), (1, 1), (0, 1), (1, 0). All these satisfy the inequality x2 + y2 < 4Input −n=2Output − distinct pairs= 3Explanation &minus pairs will be (0, 0), (0, ... Read More

1K+ Views
The abnormal behavior of C++ programs often leads to program crash. You may have encountered problems like Segmentation fault, Aborted, Floating point exception etc. Following are sample programs that may help you to understand the reasons for a C++ program crash.ExceptionsExceptions in C++ are responses of a program when it encounters an abnormal condition. The program crashes due to such exceptions if they are not handled properly using try-catch blocks. Following program crashes due to divide by zero exception −Example Live Demo#include int main(){ int num1=10; int num2=0; int quotient=num1/num2; printf(" Quotient is: %d", quotient); ... Read More

6K+ Views
Given three inputs first one is “a” which is for the first term of geometric series second is “r” which is the common ratio and “n” which are the number of series whose sum we have to find.Geometric series is a series which have a constant ratio between its successive terms. Using the above stated inputs “a”, “r” and “n” we have to find the geometric series i.e., a, ar, 𝑎𝑟2 , 𝑎𝑟3 , 𝑎𝑟4 , … and their sum, i.e., a + ar + 𝑎𝑟2+ 𝑎𝑟3 + 𝑎𝑟4 +…Inputa = 1 r = 0.5 n = 5Output1.937500Inputa = 2 ... Read More

322 Views
Given a number n, the task is to print the triangular patterns of alphabets of the length n. First print the n characters then decrement one from the beginning in each line.The triangular pattern of alphabet will be like in the given figure below −Input − n = 5Output Input − n = 3Output Approach used below is as follows to solve the problemTake input n and loop i from 1 to n.For every i iterate j from i to n for every j print a character subtract 1 and add the value of j to ‘A’ .AlgorithmStart In function int pattern( ... Read More

3K+ Views
Given a certain cost price(cp) and a selling price(sp) of an unknown product or a service, our task is to find the profit earned or loss suffered using a C program where if the profit is earned should print “Profit” and it’s amount or if the loss is suffered “Loss” and its respective amount or if there is not profit no loss then print “No profit nor Loss”.To find the profit or the loss we generally see whether the selling price(sp) or the price/amount at which a certain thing is sold or the cost price(cp) at which a certain thing ... Read More

284 Views
Given an integer array arr[] with some elements, the task is to find the product of all the prime number of that numbers.Prime number are those number which are either divided by 1 or the number itself, or a prime number is a number which is not divisible by any other number except 1 and the number itself. Like 1, 2, 3, 5, 7, 11, etc.we have to find the solution for the given array −Input −arr[] = { 11, 20, 31, 4, 5, 6, 70 }Output − 1705Explanation − Prime numbers in array are − 11, 31, 5 their ... Read More