[go: up one dir, main page]

0% found this document useful (0 votes)
19 views4 pages

Structured_Programming_Exam_New

The document is an exam paper for a Structured Programming course (CS101) containing 40 multiple-choice questions focused on C++ programming concepts. Topics include functions, loops, arrays, memory allocation, pointers, constructors, destructors, and object-oriented programming principles. The exam is designed to assess students' understanding of fundamental programming concepts within a 60-minute timeframe for a total of 40 marks.

Uploaded by

masrymo271
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)
19 views4 pages

Structured_Programming_Exam_New

The document is an exam paper for a Structured Programming course (CS101) containing 40 multiple-choice questions focused on C++ programming concepts. Topics include functions, loops, arrays, memory allocation, pointers, constructors, destructors, and object-oriented programming principles. The exam is designed to assess students' understanding of fundamental programming concepts within a 60-minute timeframe for a total of 40 marks.

Uploaded by

masrymo271
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
You are on page 1/ 4

Structured Programming Exam (New Questions)

Faculty: [Your Faculty Name] University: [Your University Name]

Course Code: CS101 Subject: Structured Programming

Date: [Exam Date] Time: 60 Minutes Total Marks: 40 Marks

1. What is the purpose of a function in C++?

A. To define a loop B. To group reusable code C. To allocate memory D. To declare a variable

2. Which of the following loops is used when the number of iterations is fixed?

A. for loop B. while loop C. do-while loop D. infinite loop

3. What is the correct way to declare an array in C++?

A. int arr[5]; B. int arr; C. array<int> arr; D. int[5] arr;

4. Which keyword is used to allocate memory dynamically in C++?

A. malloc B. new C. create D. allocate

5. What is the index of the first element in an array in C++?

A. 1 B. -1 C. 0 D. Depends on the type

6. What will happen if you access an array index out of bounds in C++?

A. Program throws an exception B. Program crashes C. Undefined behavior D. Compiler error

7. Which operator is used to access the value pointed to by a pointer?

A. & B. * C. -> D. .

8. What is the output of the following statement: cout << 2 * 3 + 4 / 2;

A. 7 B. 8 C. 10 D. 9

9. How is a constant defined in C++?

A. const int x = 10; B. constant int x = 10; C. define const int x = 10; D. immutable int x = 10;

10. Which of the following is not a type of error in programming?


A. Syntax error B. Logical error C. Compilation error D. Debugging error

11. What does the break statement do in a loop?

A. Ends the program B. Skips the current iteration C. Exits the loop D. Pauses execution

12. What is the syntax to declare a function in C++?

A. function func(); B. void func(); C. declare void func(); D. def void func();

13. What is recursion?

A. A function calling another function B. A function calling itself C. A loop within a function D.

Nested functions

14. What is the return type of the 'main()' function?

A. int B. void C. double D. char

15. How do you declare a pointer in C++?

A. int p*; B. int *p; C. pointer int p; D. int p&;

16. What is the default value of a pointer in C++?

A. 0 B. nullptr C. undefined D. NULL

17. What does the sizeof operator return?

A. Length of an array B. Size of a data type in bytes C. Size of the program D. Number of

variables

18. Which of the following is a preprocessor directive in C++?

A. #include B. include C. import D. define

19. What does the statement 'delete ptr;' do in C++?

A. Deallocates memory pointed by ptr B. Deletes ptr from memory C. Deletes all variables D.

Creates a pointer

20. Which type of loop checks the condition after executing the loop body?

A. for loop B. while loop C. do-while loop D. Nested loop


21. What is the purpose of the continue statement?

A. End a loop B. Skip to the next iteration C. Restart the loop D. End the program

22. How do you define a function that does not return a value?

A. void func(); B. null func(); C. empty func(); D. nothing func();

23. Which operator is used to access members of a structure?

A. -> B. * C. . D. &

24. What is a default constructor in C++?

A. A constructor with default arguments B. A constructor that takes no arguments C. A

constructor that initializes pointers D. A constructor that is deleted

25. Which of the following keywords is used to create an object in C++?

A. create B. new C. object D. instance

26. What does a destructor do in C++?

A. Creates an object B. Deletes an object C. Initializes an object D. Cleans up resources

27. How do you pass a parameter by reference?

A. int func(int x); B. int func(int &x); C. int func(int *x); D. int func(x);

28. Which of the following is an invalid array declaration?

A. int arr[10]; B. float arr[5]; C. int arr[-5]; D. char arr[20];

29. What does the operator '->' do?

A. Dereferences a pointer B. Accesses a member of a pointer object C. Accesses a member of

a structure D. Multiplies two values

30. How do you dynamically allocate an array in C++?

A. int arr = new int[10]; B. int *arr = new int[10]; C. int arr[10]; D. new int arr[10];

31. What is the difference between '==' and '=' in C++?

A. No difference B. '==' is assignment, '=' is comparison C. '==' is comparison, '=' is assignment

D. Both are used for assignment


32. What is a namespace in C++?

A. A container for variables and functions B. A type of variable C. A memory location D. A

pointer type

33. Which of the following keywords is used to inherit a class?

A. extend B. inherit C. public D. class

34. What is the purpose of the virtual keyword in C++?

A. To create an abstract class B. To allow function overriding C. To define a global variable D.

To allocate memory

35. What is an inline function?

A. A function defined in a header file B. A function whose code is expanded at runtime C. A

function whose code is expanded at compile time D. A function with no parameters

36. What does 'cin' do in C++?

A. Reads input B. Prints output C. Declares a variable D. Creates a loop

37. How do you declare a two-dimensional array?

A. int arr[2, 3]; B. int arr[2][3]; C. int arr(2, 3); D. int arr[2][3][];

38. What is polymorphism in C++?

A. The ability of a function to take multiple forms B. A type of loop C. A pointer operation D. A

type of variable

39. What does the keyword 'this' represent in C++?

A. The base class B. The current object C. A global variable D. A local variable

40. Which of the following is not a valid keyword in C++?

A. private B. public C. static D. constant

You might also like