0% found this document useful (0 votes)
5 views1 page

C Programming Exam: Theory & Practice

The document outlines a C programming exam consisting of theoretical questions and practical coding tasks. Section A includes questions on data types, control structures, recursion, arrays, strings, and variable scope. Section B consists of coding exercises that require implementing various functions and algorithms in C.

Uploaded by

riraka7029
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

C Programming Exam: Theory & Practice

The document outlines a C programming exam consisting of theoretical questions and practical coding tasks. Section A includes questions on data types, control structures, recursion, arrays, strings, and variable scope. Section B consists of coding exercises that require implementing various functions and algorithms in C.

Uploaded by

riraka7029
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

C program exam

🔹 Section A: Theoretical Questions

1. Define primitive data types in C with examples.


2. What is the syntax of an if-else statement? Write a sample use case.
3. Explain the use of the while loop. How is it different from the for loop?
4. What is the purpose of switch-case? When should it be used over if-else?
5. What is recursion? Why is it sometimes preferred over iteration?
6. Differentiate between call by value and call by reference using diagrams and example
code.
7. Compare and contrast a 1D array with a 2D array in terms of memory and access.
8. What are common pitfalls in using strings in C? How does C handle string termination?
9. Explain scope and lifetime of a variable in C with example for local and global
variables.
10. Write the dry run (step-by-step execution) of a recursive function calculating Fibonacci
numbers.

🔹 Section B: Practical Coding Questions

11. Write a program to input two numbers and print their sum, difference, and product.
12. Write a program to print all even numbers from 1 to 50 using a while loop.
13. Create a switch-case program to take a day number (1–7) and print the corresponding
weekday.
14. Write a function to calculate and return the square of a number using pass by value.
15. Write a recursive function to calculate the factorial of a number.
16. Write a program to accept 10 integers into an array and display only the prime numbers.
17. Input a 3x3 matrix and calculate the sum of the left and right diagonals separately.
18. Write a program using a function to accept a string and return the number of vowels.
19. Write a program to sort an array of integers in ascending order using a loop (no built-
in functions).
20. Write a program to check whether a string is a palindrome or not without using
strrev().

You might also like