Unit I – Introduction to C
1. Which of the following is not a valid C identifier?
A) _sum
B) 2value
C) total_value
D) value2
Answer: B
2. Which is the correct keyword for defining a constant in C?
A) const
B) define
C) constant
D) static
Answer: A
3. The size of float in C is typically:
A) 1 byte
B) 2 bytes
C) 4 bytes
D) 8 bytes
Answer: C
4. Which of the following is a logical operator in C?
A) &&
B) &
C) |
D) ^
Answer: A
5. Which operator has the highest precedence?
A) =
B) +
C) *
D) &&
Answer: C
6. Which C statement is used to read formatted input?
A) scanf
B) printf
C) gets
D) putchar
Answer: A
7. Which symbol is used for comments in C?
A) /…/
B) //
C) Both A and B
D) #
Answer: C
8. What is the output of printf("%d", 'A');?
A) A
B) 65
C) 97
D) Error
Answer: B
9. Which of the following is a bitwise operator?
A) &&
B) |
C) ||
D) ==
Answer: B
10. What is the correct syntax to define a symbolic constant?
A) #define PI 3.14
B) const PI = 3.14;
C) PI = 3.14;
D) #constant PI 3.14
Answer: A
11. Which is used to get a character input from user?
A) getchar()
B) gets()
C) scanf("%d")
D) putchar()
Answer: A
12. What does the increment operator ++ do?
A) Decrease by 1
B) Increase by 1
C) Multiply by 2
D) Divide by 2
Answer: B
13. Which type conversion happens automatically in expressions?
A) Implicit
B) Explicit
C) Forced
D) Manual
Answer: A
14. Which of the following is not a C token?
A) Keyword
B) Identifier
C) Operator
D) Function
Answer: D
15. Which header file is required for mathematical functions like sqrt()?
A) stdio.h
B) conio.h
C) math.h
D) string.h
Answer: C
16. The output of printf("%c", 65); is:
A) 65
B) A
C) a
D) Error
Answer: B
17. Which of the following is a special operator in C?
A) sizeof
B) +
C) -
D) *
Answer: A
18. What is the keyword to declare a variable of integer type?
A) int
B) float
C) char
D) double
Answer: A
19. Which operator is used for conditional expressions?
A) ?:
B) &&
C) ||
D) ==
Answer: A
20. Which function is used to write a character to stdout?
A) putchar()
B) printf()
C) scanf()
D) getchar()
Answer: A
5-Mark Questions
1. Explain the character set, tokens, and identifiers in C.
2. Write short notes on data types and declaration of variables in C.
3. Explain arithmetic, relational, and logical operators with examples.
4. Describe the concept of type conversion in expressions.
5. Explain formatted input and output in C with examples of scanf and printf.
10-Mark Questions
1. Explain C constants, variables, and symbolic constants with examples.
2. Discuss all types of operators in C with precedence and associativity.
3. Explain arithmetic expressions, evaluation, and type conversion with examples.
4. Write a C program to read a character and display its ASCII value.
5. Explain formatted input/output functions in C and their uses.
Unit II – Decision Making, Looping & Arrays (20 MCQs)
1. Which statement is used for unconditional jump?
A) break
B) continue
C) goto
D) exit
Answer: C
2. Which loop executes at least once?
A) while
B) do…while
C) for
D) None
Answer: B
3. The ?: operator is also called:
A) Ternary operator
B) Conditional operator
C) Relational operator
D) Logical operator
Answer: B
4. Which statement is used to exit a loop immediately?
A) continue
B) break
C) return
D) exit
Answer: B
5. Which loop is suitable when the number of iterations is known beforehand?
A) while
B) do…while
C) for
D) if
Answer: C
6. Which statement is used for multiple branching based on variable value?
A) if
B) switch
C) while
D) for
Answer: B
7. Which keyword is used to skip the current iteration?
A) break
B) continue
C) goto
D) return
Answer: B
8. How is a 1-D integer array of size 10 declared?
A) int arr[10];
B) int arr(10);
C) int arr{};
D) int arr;
Answer: A
9. Which of the following is used to store a string in C?
A) int array
B) char array
C) float array
D) double array
Answer: B
10. What is the value of arr[0] in int arr[5]={1,2,3};?
A) 0
B) 1
C) 3
D) Undefined
Answer: B
11. Which statement is true about nested loops?
A) Outer loop cannot be a for loop
B) Inner loop executes once for each outer loop iteration
C) Inner loop executes only once
D) Nested loops are not allowed in C
Answer: B
12. The switch statement evaluates:
A) Condition
B) Expression
C) Loop variable
D) Function return type
Answer: B
13. Can a switch statement have multiple case labels with same value?
A) Yes
B) No
C) Only in C++
D) Only in nested switch
Answer: B
14. How are strings terminated in C?
A) NULL
B) '\n'
C) '\0'
D) EOF
Answer: C
15. Which loop is best for an indefinite loop?
A) for
B) while
C) do…while
D) if
Answer: B
16. Which array index is used for the first element?
A) -1
B) 0
C) 1
D) Depends on compiler
Answer: B
17. What will break inside a switch do?
A) Exit the switch
B) Continue next iteration
C) Exit program
D) Go to default
Answer: A
18. Can arrays in C be passed to functions?
A) Yes
B) No
C) Only 1-D arrays
D) Only global arrays
Answer: A
19. What is the output of printf("%d", sizeof(arr)); for int arr[10];?
A) 10
B) 40 (assuming 4 bytes per int)
C) 4
D) 0
Answer: B
20. Which operator is used for relational comparison?
A) ==
B) =
C) +=
D) ++
Answer: A
5-Mark Questions
1. Explain the different decision-making statements in C with examples.
2. Write short notes on nested if…else and else if ladder.
3. Explain switch statement with syntax and example.
4. Describe the types of loops in C with flowchart.
5. Explain character arrays and strings with examples.
10-Mark Questions
1. Write a C program to find the largest of three numbers using if…else.
2. Explain all loop statements in C with syntax, flowchart, and examples.
3. Write a C program to print Fibonacci series using for loop.
4. Write a C program to reverse a string using character array.
5. Explain the use of break, continue, and goto statements with examples.
Unit III – C++ Basics & OOP Concepts
1. Which of the following is not a feature of OOP?
A) Encapsulation
B) Inheritance
C) Polymorphism
D) goto
Answer: D
2. What is the purpose of a constructor in C++?
A) To destroy objects
B) To initialize objects
C) To handle exceptions
D) To overload operators
Answer: B
3. Destructor is called:
A) When object is declared
B) When object goes out of scope
C) After constructor
D) Only for static objects
Answer: B
4. Inline functions are used to:
A) Reduce memory usage
B) Reduce function call overhead
C) Increase execution time
D) Allocate dynamic memory
Answer: B
5. Function overloading allows:
A) Same function name with same parameters
B) Same function name with different parameters
C) Different function names with same parameters
D) Only inline functions
Answer: B
6. Which operator is used to access members of an object?
A) .
B) ->
C) *
D) &
Answer: A
7. Friend function can access:
A) Only public members
B) Private and protected members
C) Only static members
D) Only constructors
Answer: B
8. Static member variables:
A) Are unique for each object
B) Are shared across all objects
C) Cannot be accessed by objects
D) Must be initialized inside class
Answer: B
9. Array of objects can be used for:
A) Storing multiple objects of same class
B) Storing only integers
C) Declaring multiple pointers
D) None
Answer: A
10. Bitfields in classes are used to:
A) Store large integers
B) Save memory by storing small integers
C) Define methods
D) Define arrays
Answer: B
11. Which of the following is correct syntax to declare an object?
A) ClassName obj;
B) obj ClassName;
C) ClassName *obj;
D) new ClassName;
Answer: A
12. Which of the following can be overloaded in C++?
A) +, -, *, /
B) sizeof
C) .
D) ::
Answer: A
13. Constructor overloading allows:
A) Multiple constructors with same name and same parameters
B) Multiple constructors with different parameters
C) Only one constructor per class
D) Only default constructor
Answer: B
14. Which of the following is a correct declaration of inline function?
A) inline int add(int a, int b){return a+b;}
B) int inline add(int a, int b){return a+b;}
C) int add(inline a, b){return a+b;}
D) inline int add(a, b){return a+b;}
Answer: A
15. Which of the following is true about member functions?
A) They can access only public data members
B) They can access all data members including private and protected
C) They cannot access private members
D) They are static by default
Answer: B
16. Which keyword is used to declare constant member function?
A) const
B) static
C) friend
D) volatile
Answer: A
17. Overloading member functions means:
A) Same function name with different signatures in the same class
B) Functions with same parameters
C) Friend functions only
D) Static functions only
Answer: A
18. Which of the following is true for a default constructor?
A) Takes no arguments
B) Can take arguments
C) Must be inline
D) Cannot be overloaded
Answer: A
19. The I/O stream objects cin and cout are defined in which header file?
A) stdio.h
B) iostream
C) conio.h
D) string.h
Answer: B
20. Which statement is true for C++?
A) Only supports procedural programming
B) Supports object-oriented and procedural programming
C) Does not support functions
D) Cannot handle classes
Answer: B
5-Mark Questions
1. Explain key concepts of Object-Oriented Programming.
2. Write short notes on C++ I/O using cin and cout.
3. Explain inline functions and function overloading with examples.
4. Explain static data members and static member functions with examples.
5. Explain constructor and destructor in C++ with examples.
10-Mark Questions
1. Explain the differences between C and C++ with examples.
2. Write a C++ program using class and objects to calculate area of a rectangle.
3. Explain friend functions and their uses with examples.
4. Explain array of objects and overloading member functions in C++.
5. Discuss advantages of Object-Oriented Programming over procedural programming.
Unit IV – Inheritance & Operator Overloading
1. Which of the following is true about inheritance?
A) Derived class cannot access base class members
B) Inheritance allows code reusability
C) C++ does not support multiple inheritance
D) Inheritance is not part of OOP
Answer: B
2. Which inheritance type allows a derived class to inherit from multiple base classes?
A) Single
B) Multiple
C) Multilevel
D) Hierarchical
Answer: B
3. What is the correct syntax for single inheritance?
A) class Derived: public Base {}
B) class Base: public Derived {}
C) class Derived { Base; }
D) class Base {} Derived {}
Answer: A
4. Which inheritance type creates a diamond problem?
A) Single
B) Multilevel
C) Multiple
D) Hierarchical
Answer: C
5. Virtual base classes are used to:
A) Increase memory
B) Avoid multiple copies of base class
C) Inherit private members
D) Override constructors
Answer: B
6. Abstract classes contain:
A) Only data members
B) Pure virtual functions
C) Only constructors
D) Only destructors
Answer: B
7. Which operator is unary?
A) +
B) ++
C) + (binary)
D) * (binary)
Answer: B
8. Binary operator overloading requires:
A) One operand
B) Two operands
C) Three operands
D) Only friend function
Answer: B
9. Which of the following cannot be overloaded?
A) +
B) =
C) . (dot)
D) <<
Answer: C
10. Friend functions can be used to:
A) Overload operators
B) Access private members
C) Both A and B
D) None of the above
Answer: C
11. Which keyword is used to declare a pure virtual function?
A) abstract
B) virtual … =0
C) pure
D) const
Answer: B
12. Type conversion between classes can be done using:
A) Constructor
B) Operator overloading
C) Both A and B
D) None
Answer: C
13. Which of the following is correct for multilevel inheritance?
A) Class C: public B, public A {}
B) Class B: public A {}; Class C: public B {}
C) Class A: public B {}; Class C: public B {}
D) Class A {}; Class B {}; Class C {};
Answer: B
14. Which operator overloading allows friend functions?
A) Unary
B) Binary
C) Both unary and binary
D) Only relational operators
Answer: C
15. Which of the following statements is true?
A) Private members of base class are accessible to derived class
B) Protected members are accessible to derived class
C) Public members are inaccessible to derived class
D) Static members cannot be inherited
Answer: B
16. Which of the following is true about operator overloading?
A) We can change precedence of operators
B) We can change number of operands
C) We cannot change operator meaning
D) We can define new operators
Answer: B
17. Which inheritance type allows a base class to have multiple derived classes?
A) Single
B) Multiple
C) Hierarchical
D) Multilevel
Answer: C
18. Can constructors be inherited?
A) Yes, always
B) No, never
C) Only in C++11 using using-declaration
D) Only for virtual base classes
Answer: C
19. Which operator is used for stream insertion?
A) >>
B) <<
C) +
D) &
Answer: B
20. What is the purpose of abstract classes?
A) Cannot be instantiated
B) Provides base interface for derived classes
C) Can have pure virtual functions
D) All of the above
Answer: D
5-Mark Questions
1. Explain unary and binary operator overloading with examples.
2. Write short notes on friend functions used in operator overloading.
3. Explain type conversion between classes with examples.
4. Explain types of inheritance in C++ with a diagram.
5. Write short notes on abstract classes and virtual base classes.
10-Mark Questions
1. Write a C++ program demonstrating operator overloading for adding two complex
numbers.
2. Explain single, multiple, multilevel, hierarchical, hybrid, and multipath inheritance with
diagrams.
3. Write a C++ program showing use of abstract class and pure virtual functions.
4. Explain friend functions and their use in operator overloading with example.
5. Discuss advantages and disadvantages of multiple inheritance in C++.
Unit V – Pointers, Files & Advanced Features
1. What does the this pointer refer to in C++?
A) Base class object
B) Current object
C) Derived class object
D) NULL
Answer: B
2. Pointer to an object can be declared using:
A) ClassName ptr;
B) ClassName ptr;
C) *ClassName ptr;
D) ClassName &ptr;
Answer: A
3. Which operator is used to access members through a pointer?
A) .
B) ->
C) *
D) &
Answer: B
4. Dynamic memory allocation in C++ is done using:
A) malloc
B) new
C) alloc
D) create
Answer: B
5. Which file mode is used to read a binary file?
A) "r"
B) "rb"
C) "w"
D) "wb"
Answer: B
6. Which file mode is used to append data to an existing file?
A) "w"
B) "a"
C) "r"
D) "rb"
Answer: B
7. Which of the following is correct for sequential file reading?
A) fstream file("data.txt"); file >> x;
B) ifstream file("data.txt"); file >> x;
C) ofstream file("data.txt"); file >> x;
D) file.read(x);
Answer: B
8. Random file access functions include:
A) seekg and seekp
B) getline
C) eof
D) write
Answer: A
9. Which of the following is used to handle exceptions?
A) try
B) catch
C) throw
D) All of the above
Answer: D
10. Templates are used in C++ for:
A) File handling
B) Exception handling
C) Generic programming
D) Pointers
Answer: C
11. The delete operator is used to:
A) Free memory allocated by malloc
B) Free memory allocated by new
C) Remove files
D) Close streams
Answer: B
12. ifstream is used for:
A) Writing to files
B) Reading from files
C) Both reading and writing
D) Closing files
Answer: B
13. ofstream is used for:
A) Writing to files
B) Reading from files
C) Both reading and writing
D) Closing files
Answer: A
14. What is the size of a pointer in most 32-bit systems?
A) 1 byte
B) 2 bytes
C) 4 bytes
D) 8 bytes
Answer: C
15. Which of the following is true about this pointer?
A) Points to base class object
B) Points to current object of the class
C) Points to derived class object only
D) Always NULL
Answer: B
16. Which of the following file streams is used for both reading and writing?
A) ifstream
B) ofstream
C) fstream
D) stream
Answer: C
17. What is the purpose of templates?
A) Reduce code duplication
B) Handle exceptions
C) Access files
D) Allocate memory dynamically
Answer: A
18. Which of the following is true about exception handling?
A) try block contains code that may throw exceptions
B) catch block handles exceptions
C) throw statement raises exceptions
D) All of the above
Answer: D
19. Pointer to derived class can:
A) Access only derived class members
B) Access base class members
C) Access both base and derived class members through casting
D) None of the above
Answer: C
20. Which of the following is a valid way to declare a pointer to an array of objects?
A) ClassName *ptr = new ClassName[10];
B) ClassName ptr[10];
C) ClassName ptr[10];
D) ClassName ptr = new ClassName[10];
Answer: A
5-Mark Questions
1. Explain pointers to class and objects with examples.
2. Explain this pointer in C++ with example.
3. Explain file handling operations in C++ (sequential and random access).
4. Write short notes on templates and their use.
5. Explain exception handling in C++ with try
Unit V – 10-Mark Questions
1. Explain pointers in C++ with examples.
2. Explain file handling in C++ with different file modes.
3. Explain dynamic memory allocation using new and delete in C++.
4. Explain templates in C++ with examples of function and class templates.
5. Explain exception handling in C++ using try, catch, and throw.