C PROGRAMMING
Comprehensive Practice Question Bank
Algorithms & Flowcharts
• Write an algorithm to check whether the entered number is Even or Odd.
• Write an algorithm to find factorial of given number by user input.
• Draw a flowchart to check whether the entered number is prime or not.
• Write an algorithm and draw the flowchart to calculate sum of digits of a given number N.
Definitions & C Basics
• What is Software? List various types of Software.
• Define following terms: Application Software, System Software, Algorithm, Flowchart.
• Define following terms: Compiler, Runtime Error, Dynamic Memory Allocation, Recursion.
• Explain the basic structure of a C program with an example.
• List and explain different data types available in C.
Operators & Expressions
• Explain different type of operators used in c language with their precedence and associativity.
• Demonstrate the working of ternary operator and sizeof operator with an example.
• Explain type casting with example.
• What is type conversion? Explain two types of conversion with examples.
• Evaluate given C programming Expressions:
◦ Ans = 10 + 4 * 3 / 2;
◦ Ans = while(1);
◦ Ans = 3 * 2 > 3 + 1;
◦ Ans = (2 + 4) > 3 && 2 < 4;
Control Structures (Loops & Decision Making)
• Explain switch statement with an example.
• Explain nested if-else statement with suitable example.
• Explain else...if ladder with example.
• Discuss the need of break and continue statements with example.
• Differentiate between break and continue .
• Differentiate while and do..while loop with example.
• Find out error(s), if any in the following code and correct it:
int main() {
if(25 % 2 == 0) {
break;
}
}
• Write a C program to check whether the entered character is alphabet, digit, space or any special
character.
• Write a C program to find the largest number amongst three integers entered.
• Write a C program which takes marks (between 0 to 100) of a student for N subjects and prints the
grade based on percentage conditions.
• Write a C program that takes three coefficients of a quadratic equation (ax2 + bx + c) as input and
compute all possible roots and print them with appropriate messages.
Number, Math, & Pattern Programs
• Write a C program to make sum of digits of a given number.
• Write a C program to find factorial of a given number.
• Write a C program to check weather given integer number is palindrome or not?
• Write a program in C to calculate the power of any number using recursion.
• Write a C program to print following pattern (Input 4: 1, 22, 333, 4444 ).
• Write a C program to print following pattern (Input 5: 1, 22, 333, 4444, 55555 ).
• Write a C program to print the following pattern as output: A, BC, DEF, GHIJ .
Arrays & Strings
• List the types of Array.
• Summarize the methods for initialization of One-Dimensional array.
• Demonstrate declaration and initialization of two dimensional array with suitable example.
• Write a C program to sort an array in ascending order.
• Write a program to find out the maximum number from integer array of 5 elements.
• Write a program in c for multiply two matrices A and B of dimensions M × N and N × O respectively
and store the result in third matrix C.
• Write a C program which takes two N × N matrices and performs matrix multiplication.
• What is string? How to declare string in C?
• Explain the significance of following string functions with example: strcat() , strlen() ,
strcpy() , strcmp() .
• Write a C program to count total number of vowel in given string.
• Write a C program that reads a statement from user and prints the frequency of each of the distinct
character from a-z.
Functions
• What is function? Differentiate between call by value and call by reference with example.
• Differentiate call by value and call by reference.
• Demonstrate the use of recursion with an example.
• What are the steps in writing a recursive function in a program?
• Explain getch() , putch() , gets() , puts() .
• Demonstrate the use of void with example.
Pointers & Memory Allocation
• What is pointer? Explain how pointers are declared and initialized.
• What is a pointer? What are the advantages of using pointer?
• Demonstrate the pointer arithmetic with example.
• Write a C program to find the sum and mean of all elements in an array using pointer.
• Define dynamic memory allocation. Explain malloc() and calloc() with example.
• Explain need of Dynamic Memory allocation. Compare malloc() , calloc() and realloc()
functions.
• Briefly explain memory management functions.
Structures & Unions
• Discuss/Explain Nested structure with example.
• Compare Array, Structure and Union.
• State the use of Union in 'C' with example.
• Define Union. Describe how to declare, initialize and access members of Union with a programming
example.
File Handling
• Write a c program to copy content of one file (or text file) into another file.
• Write a c program to read a file and count total no of lines, total no. of words and total number of
characters.
• Demonstrate the use of fopen() and fprintf() function of file handling.
• Show the use of fclose() and fscanf() function of file handling.
• What is File Pointer? What is significance of File Pointer?
• Explain signification of following functions in file operations: fseek() , ftell() , open() ,
fread() .
• Write a C program to read ID and marks of n number of students from user and store them in a file.
Generated Question Bank • C Programming & Data Structures