PPC Assignment – 2
1. List the different forms of the if statement available in C.
2. Differentiate between while (Entry-controlled) and do-while (Exit-controlled) loops
with a syntax example.
3. What is the purpose of the default label in a switch statement? Is it mandatory?
4. Explain the difference between break and continue statements with a specific example
for each.
5. Define an Array. Mention two major disadvantages of using static arrays.
6. How is a 2D array stored in memory? (Row-major vs. Column-major). List the
advantages and disadvantages of arrays in C.
7. Differentiate between Linear Search and Binary Search in terms of prerequisite
conditions.
8. How does the C compiler recognize the end of a string? What is the specific character
used?
9. List four commonly used string handling functions defined in <string.h> and their
purposes.
10. Write a C program to input a number and check whether it is positive, negative, or zero
using if-else.
11. Write a C program using a switch statement to display the day of the week when a
number (1–7) is entered.
12. Write a C program to demonstrate the use of nested loops by printing a multiplication
table (1 to 10).
13. Write a C program to search an element in a single-dimensional array using linear
search.
14. Write a C program to count the number of vowels and consonants in a given string.
15. Write a C program to sort an array of integers in ascending order using Bubble Sort.
16. Write a C program to input a string and check whether it is a palindrome or not.
17. Write a C program to input a matrix (2D array) and calculate the sum of its diagonal
elements.
18. Write a C program to demonstrate the use of string handling functions (strlen,
strcpy, strcmp, strcat) with examples.
19. Write a program to check if a given integer is a Prime Number or not.
20. Write a C program to read N integers into an array and find the largest and smallest
numbers in that array.
21. Explain the logic of Bubble Sort and write a code to sort an array of 5 integers in
ascending order.
22. Write a C program to read a string from the user and count the number of Vowels,
Consonants, and Spaces in it.
23. Write a user-defined function int my_strlen(char str[]) that calculates the length of
a string without using the library function strlen().
24. Write a C program to input marks of five subjects and calculate the grade using if-else
conditions.
o Example: ≥ 75 → Distinction, ≥ 60 → First Class, ≥ 50 → Second Class, else →
Fail.
25. Write a menu-driven program using a do-while loop and switch case that performs a
simple Calculator operation.
o Inputs: Two numbers and a choice of operation (+, -, *, /, %).
o Constraint: The program should ask the user "Do you want to continue? (y/n)"
after every calculation. If 'n', the loop terminates.
26. Write a complete C program to implement the Binary Search technique.
o Read N elements into an array.
o Sort the array (or assume the user inputs sorted data).
o Accept a key element to search.
o Print the position of the key if found, otherwise print "Element not found".