Category Archives: C Programming

Find Largest Area Triangle from 2D Matrix

Problem: Given a table of size n * m, with each cell having a color value from the set {r, g, b}, find the area of the largest triangle that has one side parallel with the y – axis (vertical) and has no two vertices that have the same color value. Input : First line Read More →

Trie Data Structure – C Implementation

Trie Tree: A trie (from retrieval), is a multi-way tree structure useful for storing strings over an alphabet. It has been used to store large dictionaries of English (say) words in spelling-checking programs and in natural-language “understanding” programs. A trie tree uses the property that if two strings have a common prefix of length n Read More →

C Programming Quiz – Set 4

Programming Questions and Answers Our C Interview questions come with detailed explanation of the answers which helps in better understanding of C concepts. #1: Predict the output of the following C snippets a) Compiler Error b) Depends on the compiler c) 56 d) none of above Show Answer Answer: c Explanation: main is not a Read More →

C Programming Quiz – Set 3

C Programming Questions and Answers – #1: Predict the output of the following C snippets? a) nullg nullh b) Depends on the compiler c) g nullh d) g h Show Answer Answer: a Explanation: none. #2: What is the output of this C code? a) 6 b) -2 c) 0 d) None of above Show Read More →

Min Number of Platforms Required for a Railway Station

At a bus-station, you have time-table for buses arrival and departure. You need to find the minimum number of platforms so that all the buses can be placed as per their schedule. For example consider the above example. arr[] = {9:00, 9:40, 9:50, 11:00, 15:00, 18:00} dep[] = {9:10, 12:00, 11:20, 11:30, 19:00, 20:00} All Read More →

Find Seed of a Number

A number X is said to be ‘seed’ of number Y if multiplying X by its digit equates to Y. For example, 123 is a seed of 738 coz 123*1*2*3 = 738. Now given a number find all its ‘seed’. Solution:

Number of Trailing Zeros in Factorial of a Number

Write a program to output the number of consecutive trailing zeros in the factorial of a number? Solution: 1. The number of trailing zeros in a number is equivalent to the power of 10 in the factor of that number. 2. The number power of 10 in the factors is the same as the minimum Read More →

Find nth Fibonacci Number in the Fibonacci sequence?

In the Fibonacci sequence, the first two numbers are 0 and 1 and each number after that is the sum of the previous two numbers in the sequence. So, the sequence looks like this: 0, 1, 1, 2, 3, 5, 8, 13, 21… and so on. The “0″ in the sequence is considered to be Read More →

C Programming Quiz – Set 2

Programming Questions & Answers – Who should Practice these C Questions? – Anyone wishing to sharpen their skills on C programming language – Anyone preparing for aptitude test in C (both objective type test and C coding written test) – Anyone preparing for interviews (campus/off-campus interviews, walk-in interview and company interviews) #1: What is the Read More →

C Programming Quiz – Set 1

Programming Questions & Answers – You should practice these quizzes to improve your C programming skills needed for various interviews (campus interviews, walk-in interviews, company interviews), placements, entrance exams and other competitive exams. #1: Which is valid C expression? a) int my_num = 100,000; b) int my_num = 100000; c) int my num = 1000; Read More →

Largest Difference in an Array

You have an array of integers: int[] A = { 10, 3, 6, 8, 9, 4, 3 }; My goal is to find the largest difference between A[Q] and A[P] such that Q > P. If P = 1 and Q = 4 diff = A[Q] – A[P] diff = 9 – 3 diff = Read More →

Find Position of the only Set Bit

Problem: You are given a number having only one “1″ its binary representation,. You have to find position of it? Solution: First of all we will check if number is power of two, Beacuse then only its binary represenattion will contain only one “1″. After that, start from rightmost bit and one by one check Read More →