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 Loops, Constants, and Character Arrays in C

Q#1: What is the purpose of the loop in the given program?
a) To generate random numbers
b) To terminate the program
c) To search for a number in a list
d) To execute a maximum of 100 times
Answer: d) To execute a maximum of 100 times

Q#2: How many times will the loop in the program run if the size of the list is 50?
a) 50
b) 100
c) 150
d) 200
Answer: a) 50

Q#3: What is the maximum value returned by the rand() function?
a) 32767
b) 32768
c) 65535
d) 65536
Answer: a) 32767

Q#4: How can we limit the generated random number in a smaller range, such as between 1 and 6 inclusive?
a) x = rand() % 6
b) x = 1 + rand() % 6
c) x = rand() % 5
d) x = 1 + rand() % 5
Answer: b) x = 1 + rand() % 6

Q#5: What is the result of the statement rand() % 6?
a) Between 0 and 5
b) Between 1 and 6
c) Between 0 and 6
d) Between 1 and 5
Answer: a) Between 0 and 5

Q#6: How can we test if a die is fair or not?
a) Roll it 10 times
b) Roll it 100 million times
c) Use rand() % 2
d) Check the remainder of rand() % 6
Answer: b) Roll it 100 million times

Q#7: What is the purpose of the keyword ‘const’ in the program?
a) To declare an array
b) To limit the loop execution
c) To declare a constant integer
d) To generate random numbers
Answer: c) To declare a constant integer

Q#8: What does the keyword ‘const’ do in the statement “const int arraySize = 100;”?
a) Declares an array named arraySize
b) Declares a constant integer named arraySize
c) Initializes an array with size 100
d) Generates a random number with value 100
Answer: b) Declares a constant integer named arraySize

Q#9: Why is it good programming practice to use ‘const’ for array size?
a) It limits the loop execution
b) It declares a constant integer
c) It initializes the array explicitly
d) It helps in changing the array size dynamically
Answer: d) It helps in changing the array size dynamically

Q#10: What is the ASCII code of the null character in C language?
a) 0
b) 1
c) 32
d) 127
Answer: a) 0

Q#11: How does C language represent the null character?
a) “null”
b) ‘0’
c) ‘\0’
d) ” “
Answer: c) ‘\0’

Q#12: What is the purpose of the null character in character arrays?
a) It marks the end of the array
b) It represents the value zero
c) It is used for character comparison
d) It is a special character for randomness
Answer: a) It marks the end of the array

Q#13: What does the statement “cin >> name;” do?
a) Reads a single character
b) Reads a string until the space
c) Reads a string until the enter key is pressed
d) Reads a number from the user
Answer: b) Reads a string until the space

Q#14: Why is it important to be careful while declaring a character array?
a) It affects the randomness of the program
b) It determines the loop size
c) It can cause logical errors without a null character
d) It limits the size of the array
Answer: c) It can cause logical errors without a null character

Q#15: What is the size of the declared character array “char name[100];”?
a) 50
b) 100
c) 101
d) 99
Answer: b) 100

Q#16: How is a fair die defined in the given context?
a) Rolled 100 times with equal outcomes
b) Rolled 10 times with equal outcomes
c) Rolled any number of times with equal outcomes
d) Rolled 6 times with equal outcomes
Answer: a) Rolled 100 times with equal outcomes

Q#17: What is the purpose of using “rand() % 2” in the program?
a) To generate numbers between 0 and 1
b) To generate random numbers for a die
c) To test even numbers
d) To calculate the array size
Answer: a) To generate numbers between 0 and 1

Contents Copyrights Reserved By T4Tutorials