- 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
90 Views
Here we will see how to calculate the angle between two planes in the three dimensional space. The planes are P1 and P2. The equations of Pi like below −If the angle is ‘A’, then it will follow this rule −Example#include #include using namespace std; class Plane{ private: double a, b, c, d; public: Plane(double a = 0, double b = 0, double c = 0, double d = 0){ this->a = a; this->b = b; this->c = ... Read More
418 Views
Here we will see one interesting problem related to alphanumeric abbreviation of a given string. The string length is less than 10. We will print all alphanumeric abbreviations.The alphanumeric abbreviation is in the form of characters mixed with the digits. The value of that digit is number of characters that are missed. There may be any number of skipped substrings. No two substrings are adjacent to each other. Let us see the algorithm to get the idea.AlgorithmprintAbbreviation(s, index, max, str) −begin if index is same as max, then print str end if add s[index] ... Read More
180 Views
In this section we will see one interesting problem. Suppose one number is given. We have to increase this number by 1. This is extremely simple task. But here we will place the number as an array. each digit of that number is placed as an element of the array. If the number is 512, then it will be stored as {5, 1, 2}. And also we have to increase the number using recursive approach. Let us see the algorithm to get the clear idea.Algorithmincrement(arr, n, index) −Initially the default value of index is 0 begin if index < ... Read More
100 Views
Here we will see one interesting problem. Suppose one value of n is given. We have to find all strings of length n, such that there are no consecutive 1s. If n = 2, then the numbers are {00, 01, 10}, So output is 3.We can solve it using dynamic programming. Suppose we have a tables ‘a’ and ‘b’. Where arr[i] is storing the number of binary strings of length i, where no consecutive 1s are present, and ending with 0. Similarly, b is holding the same but numbers ending with 1. We can append 0 or 1 where last ... Read More
68 Views
Here we will see one interesting problem related to modular equations. Suppose we have two values A and B. We have to find number of possible value that the variable X can take, such that (A mod X) = B holds.Suppose A is 26, and B is 2. So the preferred value for X will be {3, 4, 6, 8, 12, 24} So the count will be 6. That is the answer. Let us see the algorithm to get better idea.AlgorithmpossibleWayCount(a, b) −begin if a = b, then there are infinite solutions if a < b, then there ... Read More
9K+ Views
In linear search algorithm, we compare targeted element with each element of the array. If the element is found then its position is displayed.The worst case time complexity for linear search is O(n).Input: arr[] = { 12, 35, 69, 74, 165, 54} Sea=165 Output: 165 is present at location 5.Explanationlinear search (Searching algorithm) which is used to find whether a given number is present in an array and if it is present then at what location it occurs. It is also known as sequential search. It is straightforward and works as follows: We keep on comparing each element with the ... Read More
291 Views
The program to find the minimum sum of factors of a number. The logic for solving this problem is, find all the set of factors and adding them. For every set of factors, we will do the same and then compare all of them. Then find all the minimum of these sums.Input: n=12 Output: 7ExplanationFirst find the factors of number n then sum them and try to minimize the sum. Following are different ways to factorize 12 and sum of factors in different ways.12 = 12 * 1 = 12 + 1 = 13 12 = 2 * 6 = ... Read More
7K+ Views
In this program, we are going to learn how to find the total number of lines available in a text file using C program?This program will open a file and read the file’s content character by character and finally return the total number of lines in the file. To count the number of lines we will check the available Newline () characters.Input: File "test.text" Hello friends, how are you? This is a sample file to get line numbers from the file. Output: Total number of lines are: 2ExplanationThis program will open a file and read the file’s content ... Read More
332 Views
Given two numbers dividend and divisor. The task is to write a program to find the quotient and remainder of these two numbers when the dividend is divided by the divisor.In division, we will see the relationship between the dividend, divisor, quotient, and remainder. The number which we divide is called the dividend. The number by which we divide is called the divisor. The result obtained is called the quotient. The number left over is called the remainder.55 ÷ 9 = 6 and 1 Dividend Divisor Quotient RemainderInput: Dividend = 6 Divisor = 2 Output: Quotient = 3, Remainder = ... Read More
3K+ Views
Square Matrix A is said to be skew-symmetric if aij=−aji for all i and j. In other words, we can say that matrix A is said to be skew-symmetric if transpose of matrix A is equal to negative of Matrix A i.e (AT=−A).Note that all the main diagonal elements in the skew-symmetric matrix are zero.lets take an example of a matrixA= |0 -5 4| |5 0 -1| |-4 1 0|It is skew-symmetric matrix because aij=−aji for all i and j. Example, a12 = -5 and a21=5 which means a12=−a21. Similarly, this condition holds true ... Read More