
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

173 Views
Here we will see how to find the vertex, focus directrix of a parabola using C or C++ program. To get these parameters we need the general equation of a parabola. The general formula is −𝑦 = 𝑎𝑥2 + 𝑏𝑥 + 𝑐The values of a, b and c are given.The formula for the vertex −The formula for the focus −The formula for the Directrix - y −Example Live Demo#include using namespace std; void getParabolaDetails(float a, float b, float c) { cout

193 Views
In this section we will see how to count how many of elements whose absolute values are distinct? Suppose in an array there are few elements like {5, 5, 6, -5, 8, 2, -2, 1}, so there are 8 elements. But there are 5 elements {5, 6, 8, 2, 1} which are distinct. The -5 and 5 are not considered as different, they are same as their absolute value is same.To solve this problem, we will use the Set data-structure. In set duplicate elements are not allowed. And when we are inserting item into the set, we will push only ... Read More

230 Views
Here we will see how we can find the absolute difference between the sum of all prime numbers and all non-prime numbers of an array. To solve this problem, we have to check whether a number is prime or not. One possible way for primality testing is by checking a number is not divisible by any number between 2 to square root of that number. So this process will take 𝑂(√𝑛) amount of time. Then get the sum and try to find the absolute difference.AlgorithmdiffPrimeNonPrimeSum(arr)begin sum_p := sum of all prime numbers in arr sum_np := sum of ... Read More

208 Views
Here we will see how we can find the absolute difference between the product of all prime numbers and all non-prime numbers of an array. To solve this problem, we have to check whether a number is prime or not. One possible way for primality testing is by checking a number is not divisible by any number between 2 to square root of that number. So this process will take 𝑂(√𝑛) amount of time. Then get the product and try to find the absolute difference.AlgorithmdiffPrimeNonPrimeProd(arr)begin prod_p := product of all prime numbers in arr prod_np := product of ... Read More

444 Views
Here we will see how to get the differences between first and last X digits of a number N. The number and X are given. To solve this problem, we have to find the length of the number, then cut the last x digits using modulus operator. After that cut all digits from the number except first x digits. Then get the difference, and return the result. Let the number is N = 568424. The X is 2 so first two digits are 56, and last two digits are 24. The difference is (56 - 24) = 32.AlgorithmdiffFirstLastDigits(N, X)begin ... Read More

319 Views
In this section we will see how to get the absolute difference between the sum of the roots and the products of the root of a quartic equation?The quartic equation is like 𝑎𝑥4+𝑏𝑥3+𝑐𝑥2+𝑑𝑥+𝑒We can solve the equation and then try to get the product and sum of the roots by some normal process, but that takes much time and that approach is not so efficient. In this kind of equation, we have two formulae. The Sum of roots are always −𝑏∕𝑎 and the product of roots are always 𝑒∕𝑎 . So we have to find only the value of ∣−𝑏∕𝑎− ... Read More

288 Views
Here we will see some improvements on selection sort. As we know that the selection sort works by taking either the minimum or maximum element from the array and place that element at correct position. In this approach, we want to sort the array in both ways. Here we will take the max and min simultaneously, then sort the array from two end. Let us see the algorithm to get better idea.AlgorithmtwoWaySelectionSort(arr, n)begin for i := 0, and j := n-1, increase i by 1, and decrease j by 1, until i>=j, do min := minimum ... Read More

924 Views
Here we will see one program that can tell whether two strings are rotation of each other or not. The rotation of strings is like −Suppose two strings are S1 = ‘HELLO’, and S2 = ‘LOHEL’ So they are rotation of each other. By rotating HELLO three position to the left it will be LOHEL.To solve this problem, we will concatenate the first string with itself, then check whether the second one is present in the concatenated string or not. So for HELLO, it will be HELLOHELLO. Then this concatenated string contains the LOHEL. [HELLOHELLO].AlgorithmisRotation(str1, str2)begin if lengths of ... Read More

141 Views
We know that the binary search algorithm is better than the linear search algorithm. This algorithm takes O(log n) amount of time to execute. Though most of the cases the implemented code has some problem. Let us consider one binary search algorithm function like below −Exampleint binarySearch(int array[], int start, int end, int key){ if(start key) return binarySearch(array, start, mid-1, key); return binarySearch(array, mid+1, end, key); } return -1; }This algorithm will work fine until the start and end reaches a large number. If the (start + end) ... Read More

113 Views
In this section we will see one problem. Here n elements are given in an array. We have to check whether there is a permutation of that array exists, such that each element indicates the number of elements present either before or after it.Suppose the array elements are {2, 1, 3, 3}. The appropriate permutation is like {3, 1, 2, 3}. Here the first 3 is indicating there are three elements next of it, the 1 indicates there is only one element before this. The 2 indicates there are two elements before it and the last 3 indicates that there ... Read More