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-Solved Midterm Paper

Q#1: A precise sequence of steps to solve a problem is called
(A) Statement
(B) Program
(C) Utility
(D) Routine
Answer: (B) Program

Q#2: The compiler of C language is written in
(A) Java Language
(B) UNIX
(C) FORTRAN Language
(D) C Language
Answer: (D) C Language

Q#3: Initialization of variable at the time of definition is
(A) Must
(B) Necessary
(C) Good Programming
(D) None of the given options
Answer: (C) Good Programming

Q#4: In if structure the block of statements is executed only
(A) When the condition is false
(B) When it contains arithmetic operators
(C) When it contains logical operators
(D) When the condition is true
Answer: (D) When the condition is true

Q#5: Which of the following function(s) are included in stdlib.h header file?
(A) double atof(const char *nptr)
(B) int atoi(const char *nptr)
(C) char *strcpy(char *s1, const char *s2)
(D) 1 and 2 only
Answer: (D) 1 and 2 only

Q#6: Dealing with structures and passing them by reference is the most economical method.
(A) True
(B) False
Answer: (A) True

Q#7: Pointer is a variable which stores
(A) Data
(B) Memory Address
(C) Data Type
(D) Values
Answer: (B) Memory Address

Q#8: Preprocessor program performs its function before ______ phase takes place.
(A) Editing
(B) Linking
(C) Compiling
(D) Loading
Answer: (C) Compiling

Q#9: Which of the following cannot be a variable name?
(A) area
(B) _area
(C) 10area
(D) area2
Answer: (C) 10area

Q#10: Which looping process is best when the number of iterations is known?
(A) for
(B) while
(C) do-while
(D) all looping processes require that the iterations be known
Answer: (A) for

Q#11: Which character is inserted at the end of string to indicate the end of string?
(A) new line
(B) tab
(C) null
(D) carriage return
Answer: (C) null

Q#12: How many bytes are occupied by the following array?
char str[] = “programming”;
(A) 10
(B) 11
(C) 12
(D) 13
Answer: (C) 12

Q#13: Which header file defines the rand() function?
(A) iostream.h
(B) conio.h
(C) stdlib.h
(D) stdio.h
Answer: (C) stdlib.h

Q#14: Commenting the code
(A) Makes a program easy to understand for others
(B) Makes programs heavy
(C) Makes it difficult to compile
(D) All of the given options
Answer: (A) Makes a program easy to understand for others

Q#15: What is wrong with the following for loop?
for (int k = 2, k <=12, k++)
(A) Increment should always be ++k
(B) Variable must always be i
(C) There should be semicolon at the end
(D) Commas should be semicolons
Answer: (D) Commas should be semicolons

Q#16: For which array the size should be one more than the number of elements?
(A) int
(B) double
(C) float
(D) char
Answer: (D) char


Q#17: To which category do compiler and interpreter belong?
Answer: Compiler and Interpreter belong to System Software (Language Translators).


Q#18: What is the result of the expression
x = 2 + 3 × 4 – 4 ÷ 2

Answer:
First multiplication → 3 × 4 = 12
Then division → 4 ÷ 2 = 2
Then addition and subtraction → 2 + 12 – 2 = 12


Q#19: Write a declaration statement for an array of 10 elements of type float and initialize first four elements.

Answer:
float tmp[10] = {1.0, 2.0, 3.0, 4.0};


Q#20: Write the output of the following code

int array[7], sum = 0;
for(int i=0; i<7; i++)
{
array[i] = i;
sum += array[i];
}
cout << “Sum = ” << sum;

Answer: Sum = 21


Second Code Output:

int A[5] = {1,2,3,4};
for(i=0; i<5; i++)
{
A[i] = 2*A[i];
cout << A[i] << ” “;
}

Answer: 2 4 6 8 0


Q#22: Program to check if credit limit exceeded

Answer:
Program takes input:

• Account number
• Beginning balance
• Charges
• Credits
• Credit limit

Formula:
New Balance = Beginning Balance + Charges – Credits

If New Balance > Credit Limit → Display “Credit Limit Exceeded”.
Otherwise account is within limit.

Contents Copyrights Reserved By T4Tutorials