0% found this document useful (0 votes)
25 views

Structured Programming Exam Full

The document is an exam for a Structured Programming course (CS101) consisting of 40 multiple-choice questions related to C++ programming concepts. Topics covered include data types, operators, control structures, and syntax rules. The exam is designed to assess students' understanding of fundamental programming principles in C++.

Uploaded by

masrymo271
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Structured Programming Exam Full

The document is an exam for a Structured Programming course (CS101) consisting of 40 multiple-choice questions related to C++ programming concepts. Topics covered include data types, operators, control structures, and syntax rules. The exam is designed to assess students' understanding of fundamental programming principles in C++.

Uploaded by

masrymo271
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Structured Programming Exam

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. Which of the following is not a valid data type in C++?

A. bool B. char C. text D. float

2. What does the '&&' operator represent in C++?

A. Logical OR B. Logical AND C. Bitwise OR D. Increment

3. Which statement is correct about the expression X-- in C++?

A. Decreases X by 2 B. Decreases X by 1 C. Increases X by 1 D. Keeps X unchanged

4. A line of code in C++ ends with:

A. Colon (:) B. Comma (,) C. Period (.) D. Semicolon (;)

5. Which keyword is used to define a constant in C++?

A. const B. constant C. #define D. variable

6. What does the term 'overflow' mean in programming?

A. A variable exceeds its maximum value B. A variable is not initialized C. A program runs

infinitely D. A syntax error occurs

7. What is the size of a double variable in C++ (on most systems)?

A. 2 bytes B. 4 bytes C. 8 bytes D. 16 bytes

8. Which of the following escape sequences represents a new line?

A. \n B. \t C. \r D. \

9. What is the correct syntax for including a library in C++?

A. #library <iostream> B. include #iostream C. #include <iostream> D. use <iostream>


10. What does the 'main()' function signify in a C++ program?

A. The starting point of program execution B. Declares global variables C. Prints data to the

screen D. Handles user input

11. Which operator is used for modulus operations?

A. % B. / C. // D. *

12. What value does a boolean variable default to in C++?

A. true B. false C. 0 D. Null

13. Which type of loop is guaranteed to execute at least once?

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

14. What is a variable?

A. A constant value B. A function in a program C. A symbol representing a storage location D.

A set of commands

15. Which of the following is a valid variable name in C++?

A. 1var B. var_1 C. var name D. #variable

16. What is the output of true && false?

A. true B. false C. 1 D. 0

17. What is the purpose of a 'return' statement in C++?

A. Declare a variable B. End a program C. Exit a function and optionally return a value D.

Create a loop

18. What type of error occurs when you forget a semicolon in C++?

A. Syntax error B. Logical error C. Run-time error D. Overflow

19. Which of the following is not a valid relational operator?

A. == B. != C. << D. >

20. How do you create a comment in C++?

A. // This is a comment B. ## This is a comment C. <!-- This is a comment --> D. $ This is a


comment

21. Which of the following represents a character literal?

A. "A" B. 'A' C. '123' D. """

22. What is the default value of an integer variable declared globally?

A. 0 B. 1 C. Null D. Undefined

23. What is the role of #include <iostream>?

A. Define variables B. Perform calculations C. Provide input/output functionality D. Create a

new program

24. What is the result of 10 % 3?

A. 1 B. 2 C. 3 D. 0

25. Which operator is used to access a member of an object?

A. . B. -> C. :: D. Both A and B

26. What is a valid declaration of a floating-point variable?

A. int x; B. float x; C. char x; D. bool x;

27. What is the output of !true?

A. true B. false C. 0 D. Null

28. What does the statement cout << 'Hello'; do?

A. Declares a variable B. Displays 'Hello' C. Assigns a value D. Performs a calculation

29. What is the symbol for a ternary operator?

A. ? : B. && C. == D. =

30. What is the correct data type to store 'true' and 'false'?

A. int B. char C. bool D. string

31. What does the sizeof operator do?

A. Returns the length of a string B. Returns the size of a data type in bytes C. Counts the
number of variables in a program D. Checks the type of a variable

32. Which loop will execute forever?

A. for(;;) B. while(true) C. do { } while(true); D. All of the above

33. What is a compiler?

A. A tool to run programs B. A tool to convert source code to machine code C. A tool to debug

code D. A text editor

34. What is the output of 2 + 3 * 4?

A. 20 B. 14 C. 11 D. 24

35. Which of the following correctly initializes an integer variable?

A. int x = 5; B. int x == 5; C. int x 5; D. int x:5;

36. What is the role of the break statement?

A. Restart a loop B. Exit from a loop C. Skip to the next iteration of a loop D. Pause execution

37. What does the statement int *p; mean?

A. p is an integer B. p is a pointer to an integer C. p is a character D. p is an array

38. Which of the following is a valid C++ function prototype?

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

39. What is the purpose of the return statement in main()?

A. Specify the end of the program B. Provide output C. Handle input D. Declare variables

40. What does endl do in C++?

A. Ends the program B. Adds a new line to the output C. Clears the console D. Defines a

variable

You might also like