C Programming – Unit 2 Question Paper
Total Marks: 100
Section A: Multiple Choice Questions (20 Marks)
Each question carries 2 marks.
1. 1. Which data type is used to represent decimal values in C?
a) int b) char c) float d) string
2. 2. What is the size of a double data type?
a) 16 bits b) 32 bits c) 64 bits d) 128 bits
3. 3. What will be the result of (int)8.7?
a) 8 b) 9 c) 0 d) 8.7
4. 4. What is the correct format specifier to print a character?
a) %f b) %d c) %s d) %c
5. 5. Which of the following is a valid character constant?
a) “A” b) 'A' c) A d) "A
6. 6. Which keyword is used to define a variable of floating-point type?
a) int b) float c) double d) char
7. 7. What will be the result of 22.0/10?
a) 2 b) 2.0 c) 2.2 d) 2.5
8. 8. Which escape character represents a new line?
a) \t b) \n c) \r d) \b
9. 9. Which keyword is used to create an integer variable?
a) integer b) var c) int d) num
10. 10. What is the output of printf("%c", 70);?
a) 70 b) F c) f d) Error
Section B: Short and Long Answer Questions (50 Marks)
Answer all. Marks as indicated.
Short Answer Type (3 x 5 = 15 Marks)
11. Define data types and explain different types of data types in C.
12. Explain the concept of type casting with examples.
13. What are keywords in C? List any ten keywords.
Long Answer Type (3 x 10 = 30 Marks)
14. Explain the program to compute the roots of a quadratic equation with example.
15. Write a program to calculate the average of N numbers. Explain with code and output.
16. What are constants in C? Explain integer, real, character, string and backslash constants.
Descriptive/Diagram-Based (1 x 5 = 5 Marks)
17. Explain the rules for naming variables and assigning values with examples.
Section C: Practical/Hands-On (30 Marks)
Do any two. Each carries 15 marks.
18. Write a program that takes two integers as input and swaps their values using a
temporary variable.
19. Write a program that calculates the area of a rectangle using constants for length and
width.
20. Convert the temperature in Fahrenheit to Celsius by taking user input.