- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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 1401 Articles for C
198 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]
5K+ 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
221 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
2K+ 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
136 Views
Given the numerator num and denominator den of N fractions, the task is to find the product N fractions and output should be in reduced form.Like in the given figure below we have two fractions ”4/5” and “3/4” we have found the product of those two factions where the numerator of first is multiplied by the numerator of second and the denominator of the first is multiplying the denominator of the second. Now the final result is “12/20” which can be reduced so the output shall be “3/5 ” likewise we have to develop a program to solve the given ... Read More
8K+ Views
Given are the two complex numbers in the form of a1+ ib1 and a2 + ib2, the task is to add these two complex numbers.Complex numbers are those numbers which can be expressed in the form of “a+ib” where “a” and “b” are the real numbers and i is the imaginary number which is the solution of the expression 𝑥 2 = −1 as no real number satisfies the equation that’s why it is called as imaginary number.Input a1 = 3, b1 = 8 a2 = 5, b2 = 2Output Complex number 1: 3 + i8 Complex number 2: 5 + i2 ... Read More
180 Views
Given a square matrix, mat[row][column] where row and column are equal and are of odd length means the number of row and column must me odd, i.e, not divisible by 2, the task is to find the product of middle row and middle column of that matrix.Like in the given figure below −ConstraintsMatrix must be a square matrix.Column and rows must be of odd length.Input mat[][] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}Output Product of middle row = 120 Product of middle column = 80Explanation Product of middle row = 4 * 5 * 6 = 120 Product of middle ... Read More
551 Views
Given two fractions with some numerator nume1 and nume2 and deno1 and deno2 as their respective denominator, the task is to compare both the fractions and find out the greater one. Like we have a fraction 1/2 and 2/3 and the higher one is 2/3 because the value of 1/2 is 0.5 and the value of 2/3 is 0.66667 which is higher.Input first.nume = 2, first.deno = 3 second.nume = 4, second.deno = 3Output 4/3Explanation 2/3 = 0.66667 < 4/3 = 1.33333Input first.nume = 1, first.deno = 2 second.nume = 4, second.deno = 3Output 4/3Approach used below is as follows to solve the problem//baadme likhungaAlgorithmStart ... Read More
3K+ Views
Given an array arr[] with n number of elements, our task is to check whether the given array is in sorted order or not, If it is in sorted order then print “The array is in sorted order”, else print “The array is not in sorted order”.To solve the above stated problem we can use Iterative or Recursive approach, we will be discussing both.Recursive ApproachSo, what is a Recursive approach? In Recursive approach we recursively call a function again and again until we get the desirable result. In recursive approach the values returned by function is stored in stack memory.Input arr[] ... Read More
6K+ Views
Given a string str[], the task is to check whether the string contains any special character and if the string have a special character then print “The String is not accepted” else print “The string is accepted”.Special characters are those characters which are neither numeric nor alphabetic i.e. − !@#$%^&*()+=-\][‘;/., {}|:”?`~So in C Programming language we will use if-else approach to solve the problem.Input − str[] = {“tutorials-point”}Output − the string is not acceptedInput − str[] = {“tutorialspoint”}Output − The string is acceptedApproach used below is as follows to solve the problem −Traverse the whole string.Will look for the special ... Read More