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
C Articles - Page 86 of 134
764 Views
For a number n given, we need to find whether all digits of n divide it or not i.e. if a number is ‘xy’ then both x and y should divide it.SampleInput - 24 Output - Yes Explanation - 24 % 2 == 0, 24 % 4 == 0Using conditional statements checking if each digit is non-zero and divides the number. We need to iterate over each digit of the number. And the check for the divisibility of the number for that number.Example#include int main(){ int n = 24; int temp = n; int flag=1; while (temp > ... Read More
10K+ Views
A palindrome is a word, number, phrase, or other sequences of characters which reads the same backward as forward. Words such as madam or racecar or the number 10801 are a palindrome.For a given string if reversing the string gives the same string then we can say that the given string is a palindrome. Which means to check for the palindrome, we need to find whether the first and last, second and last-1, and so on elements are equal or not.Input − naman Output − string is a palindrome Input − tutorials point Output − string is not a palindromeIn C++ Program to ... Read More
1K+ Views
To delete a tree we need to traverse each node of the tree and then delete each of them. this one by one delete every node of the tree and makes it empty. For this, we need to use a method that traverses the tree from bottom to up so that we can delete the lower notes first and then their parents so that no extra complexities arise. Based on the condition that we need, The postorder traversal will be the best suited And works efficiently so that our program will be optimum.The post-order for the following tree is -2-6-4-12-17-15The ... Read More
411 Views
A function that returns 2 for input 1 and 1 for input 2 is to be made. This function can be made in many ways based on the logic you use. The easiest way to do this is to use a conditional statement that if the number is 1 then return 2 otherwise return 1 and ways include using mathematical operations (any will do) and XOR operation.Example#include // Method 1 using the if statement int reverseif(int x) { if (x == 1) return 2; else return 1; } // Method 2 using the subtarction form sum of ... Read More
278 Views
To print any string without using a semicolon we need to find how the standard output work and why is semicolon used.The semicolon is a end of line statement that is used to tell the program that the line is ended here. The standard print statement printf used here is a method of the standard io library. Let's dig deep into the printf() method.int printf(const char *format , ...)This method returns an integer and has a set of arguments format and … . The format is a string that is printed in the output screen. And the … is the ... Read More
691 Views
In this problem, you are given N painting and we have m color that we can make paintings with and we need to find the number of ways in which we can draw the painting such that none of the same color paintings are to each other.The program’s output can have very large values and handing these values is a bit problem so we will calculate its answer in standard modulo 109 +7.The formula to find the number ways is :Ways = n*(m-1)(n-1)Example to describe the problem, this will need the number of paintings n and number of colors m ... Read More
494 Views
The surface area of any figure is the total area that it's surface cover.A hexagonal prism is a three-dimensional figure that has a hexagon at both its ends. exam on prism looks like -In mathematics, Hexagonal prism is defined as three dimensional figure with 8 faces, 18 edges, 12 vertices.Surface Area = 3ah + 3√3*(a2) Volume = (3√3/2)a2hExample#include #include int main() { float a = 5, h = 10; //Logic to find the area of hexagonal prism float Area; Area = 6 * a * h + 3 * sqrt(3) * a * a; ... Read More
545 Views
The concept of super perfect number is similar to the perfect number. It was found by D Suryanarayana in 1969. He generalized the super perfect number as a number that satisfies the following formula :sig(sig(n)) = 2nHere, sig(n) is the function that calculates the sum of divisors of a number, it is also known as divisor summatory function.The following example with making this concept clear to you :we need to check if the number N is a superperfect number or not:N = 16OutputyesExplanation − to check whether a number is a perfect number or not we will find the sum ... Read More
2K+ Views
A super-prime number is A number that occupies prime number position in the sequence of all prime numbers. also known as high order primes, These numbers occupy the position in the sequence of prime number which is equal to Prime number. some super prime numbers are 3, 5, 11, 1 7…For Example let us Find all super prime numbers less than 13 -Input 13Output3, 5, 11.Explanation − to find the super prime number less than 13 we will find all prime numbers that are less than 13. So, show all prime numbers less than 13 are 2, 3, 5, 7, 11, ... Read More
434 Views
The ASCII value of the ward is the integer presentation based on ASCII standards. In this problem, we are given a sentence and we have to calculate the sum of ASCII values of each word in the sentence.For this we will have to find the ASCII values of all the characters of the sentence and then add them up, this will give the sum of ASCII values of letters in this word. we have to do the same for all words and finally, we will add all the sums and give a final sum of ASCII values of each word ... Read More