Order PDF of any content from our website with a little minor Fee to donate for hard work. Online MCQs are fully free but PDF books are paid. For details: contact whatsapp +923028700085 Important notes based PDF Books are available in very little price, starting from 500/-PKR; Order Now: contact whatsapp +923028700085

VU Past Papers CS201-Most Importants MCQs on C++ Programming

Q#1: What does the declaration mean?
a. myptr is a constant integer
b. myptr is a constant pointer to an integer
c. myptr is a pointer to a constant integer
d. myptr is neither a constant pointer nor a constant integer
Answer: c) myptr is a pointer to a constant integer

Q#2: In the statement const int *myptr = &x;, what does myptr represent?
a. myptr is a constant integer
b. myptr is a constant pointer to an integer
c. myptr is a pointer to a constant integer
d. myptr is neither a constant pointer nor a constant integer
Answer: c) myptr is a pointer to a constant integer

Q#3: Why is the declaration useful in call by reference mechanism?
a. It allows changing the value stored at the address
b. It prevents changing the value stored at the address
c. It restricts the manipulation of the address
d. It allows changing both the value and address
Answer: b) It prevents changing the value stored at the address

Q#4: How would you declare a function that accepts a constant integer pointer as an argument?
Answer: void func(const int *ptr);

Q#5: What does the function in the given paragraph aim to do?
a. Convert a string to lowercase
b. Convert a string to uppercase
c. Convert lowercase letters of a string to uppercase
d. Convert uppercase letters of a string to lowercase
Answer: c) Convert lowercase letters of a string to uppercase

Q#6: How is the function utilized in the program?
a. It converts characters to lowercase
b. It converts characters to uppercase
c. It checks if a character is lowercase
d. It checks if a character is uppercase
Answer: b) It converts characters to uppercase

Q#7: Which library should be included for functions like tolower() and toupper()?
Answer: #include <cctype>

Q#8: What is the purpose of the statement in the given example?
a. Assign y to a constant pointer
b. Assign y to a variable pointer
c. Assign the address of the first element of y to yptr
d. Assign the value of y to yptr
Answer: c) Assign the address of the first element of y to yptr

Q#9: How does the increment of a pointer, like yptr++, behave?
a. It increments by one regardless of the data type
b. It increments by the size of the data type it points to
c. It increments by two for any data type
d. It increments by the size of the pointer variable
Answer: b) It increments by the size of the data type it points to

Q#10: What does the statement cout << *yptr; do in the context of the example?
a. Displays the memory address pointed by yptr
b. Displays the value of yptr
c. Displays the contents where yptr is pointing
d. Displays the address of y[0]
Answer: c) Displays the contents where yptr is pointing

Q#11: What is the relationship between the array name and a pointer?
a. The array name is a variable pointer
b. The array name is a constant pointer
c. The array name is not related to pointers
d. The array name is a pointer with a variable address
Answer: b) The array name is a constant pointer

Q#12: How is the memory address of the first element of an array accessed?
a. Using the array name directly
b. Using the address-of operator (&)
c. Using the array name after incrementing it
d. Using a separate pointer variable
Answer: a) Using the array name directly

Q#13: What happens if a pointer is incremented beyond the size of the array?
a. It results in an error
b. It points to the next memory location with garbage value
c. It resets to the beginning of the array
d. It becomes a constant pointer
Answer: b) It points to the next memory location with garbage value

Q#14: What determines the amount of increment when a pointer is incremented?
a. The pointer’s data type
b. The size of the array
c. The value it currently points to
d. The pointer’s constant status
Answer: a) The pointer’s data type

Q#15: How is the address of the second element of the array obtained when using a pointer?
Answer: ptr + 1 or &array[1]

Q#16: What is the primary advantage of using a constant pointer?
a. It allows changing the value stored at the address
b. It ensures the pointer always points to the same location
c. It simplifies pointer arithmetic
d. It allows changing both the value and address
Answer: b) It ensures the pointer always points to the same location

Q#17: In the statement const int *myptr, what is considered constant?
a. The value of myptr
b. The memory address myptr points to
c. The integer being pointed to by myptr
d. Both the value and memory address
Answer: c) The integer being pointed to by myptr

Q#18: How is the declaration of a constant pointer different from a regular pointer?
a. A constant pointer cannot be reassigned any other address
b. A regular pointer is always constant
c. A constant pointer allows changing the value stored at the address
d. There is no difference
Answer: a) A constant pointer cannot be reassigned any other address

Q#19: What does the lecture mention about the evolution of other languages like Java?
a. Pointers are explicitly included in modern languages
b. Pointers are explicitly excluded in modern languages
c. Pointers have no impact on language evolution
d. Pointers are optional in modern languages
Answer: b) Pointers are explicitly excluded in modern languages

Q#20: According to the summary, what are some of the topics covered in the lecture?
a. Only pointers and arrays
b. Only pointer expressions and arithmetic
c. Pointers, arrays, strings, and their relationships
d. Only tips for using pointers
Answer: c) Pointers, arrays, strings, and their relationships

Contents Copyrights Reserved By T4Tutorials