- 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
![sudhir sharma](https://www.tutorialspoint.com/assets/profiles/125719/profile/60_65058-1565947418.jpg)
124 Views
An n-sided regular polygon inscribed in a circle, the radius of this circle is given by the formula, r = a/(2*tan(180/n))Suppose a polygon have 6 faces i.e., a hexagon and as we know mathematically that the angle is 30 degreeSo the radius of circle will be (a / (2*tan(30)))Therefore, r = a√3/2We see the polygon can be divided into N equal triangles. Looking into one of the triangles, we see that the whole angle at the center can be divided into = 360/NSo, angle x = 180/n Now, tan(x) = (a / 2) * r So, r = a / ... Read More
![sudhir sharma](https://www.tutorialspoint.com/assets/profiles/125719/profile/60_65058-1565947418.jpg)
1K+ Views
To find the area of a circle inside a right angled triangle, we have the formula to find the radius of the right angled triangle, r = ( P + B – H ) / 2.Given the P, B and H are the perpendicular, base and hypotenuse respectively of a right angled triangle.Area of a circle is given by the formula, Area = π*r2where π = 22 / 7 or 3.14 and r is the radius of the circle.Hence the area of the incircle will be given by the formula, Area = π* ((P + B – H) / 2)2.Example#include ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
667 Views
Task is to print the given after the specified character occurrence for given number of times which is specified by the userInput : string = {“I am harsh vaid “} Char =’a’ Count =2 Output : rsh vaidIt means user specified character ‘a’ and its occurrence 2 so the output string should be displayed after two occurrences of a.AlgorithmSTART Step 1 -> input character in ch(e.g. ‘a’) and count(e.g. 2) as int Step 2 -> declare and initialize n with size of a string by sizeof(string)/sizeof(string[0]) Step 3 - > Loop For i to 0 and i 0 ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
92 Views
Given array with set of elements and the task is to find out set with exactly three elements having sum less than or equals to k.Input − arr[]= {1, 2, 3, 8, 5, 4}Output − set → {1, 2, 3} {1, 2, 5} {1, 2, 4} {1, 3, 5} {1, 3, 4} {1, 5, 4} {2, 3, 5} {2, 3, 4}In this, first task is to calculate the size of array depending upon which for loop of i is iterated till size-2 and for loop of j is iterated till size-1 and for loop of k is iterated till sizeAlgorithSTART Step 1 ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
1K+ Views
Given a sentence and the challenge is to find the longest palindrome from the given sentenceWhat is a Palindrome?Palindrome is a word or sequence whose meaning remains same even after reversing the stringExample − Nitin, after reversing the string its meaning remains the same.Challenge is to find the longest palindrome from the given sentence.Like sentence is: malayalam liemadameil ijiIt contains three palindrome words but the longest is − liemadameilAlgorithmSTART STEP 1 -> Declare start variables I, j, k, l, max to 0, index to -1, check to 0, count to 0 Step 2 -> Loop For i to 0 and ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
143 Views
There should be sequence of N 0’s and M 1’s such that the sequence so formed shouldn’t contain two consecutive 0’s with three consecutive 1’s.Input − N=5 M=9Output − 1 1 0 1 1 0 1 1 0 1 0 1 0 1Note − To make the above sequence, the statement (m < n-1) || m >= 2 * (n + 1) should be false if it is true than we can’t make the above sequence.It is advisable to first go through question logic and try yourself instead of jumping to the solution directly given below.AlgorithmSTART Step 1 -> take values in ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
223 Views
Print the given numeric value as words. It’s easy to do with switch using cases from 0-9 but challenge is without using them.Input − N=900Output − NINE ZERO ZEROIt is possible by creating array of pointers that contains 0-9 in words.AlgorithmSTART Step 1 -> declare int variables num, i and array of pointer char *alpha with values {"ZERO", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE"} Step 2 -> declare char array str[20] Step 3 -> call function itoa with parameters num, str, 10 Step 4 -> Loop For i=0 and str[i]!=’\o’ and i++ Print alpha[str[i] - '0'] ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
118 Views
Input number N such that 1/N will return the output generated as decimal specified till the limit.It is easy with Floating Point numbers but the challenge is without using them.Input − n=5 k=5Output − 20000It means if n=5 and k=5 than after dividing 1/5 the output should be displayed till 5 decimal points.AlgorithmStart Step 1 -> Declare int variable n to 9 and k to 7 and remain to 1 and i Step 2-> Loop for i to 0 and i end Loop For StopExample#include int main() { int n = 9, k = 7, remain=1, i ; // taking n ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
5K+ Views
Input number N and fetch the unit digit of a given number and display the multiples of that number.Input − N=326Output − unit digit is 6 and its multiples are 2 and 3Note − Unit digit of any number can be fetched by calculating the %10 with that numberFor example − if your’re given with a number N and you need to find its unit digit thatyou can use N%10 it will return you unit digit of number NALGORITHMSTART Step 1 -> Declare start variables num, num2 and i Step 2 -> input number num Step 3 -> store num%10 in num2 ... Read More