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

Past Papers CS201-Programming Important Questions and Answers

Q1: Write the declaration of the following arrays. (3 Marks)

  1. Float array of length 8
    Answer:
    An array of type float that can store 8 decimal values.
  2. Pointer to a float array of length 8
    Answer:
    A pointer variable that stores the address of the float array containing 8 elements.

Q2: Find the errors in the given program. (3 Marks)

Errors in the program:

  1. Variable number is not initialized, so it contains garbage value.
  2. The condition number/2 == 0 is incorrect for checking even numbers. It should check the remainder.
  3. The cout statement syntax is wrong because the insertion operator is missing.
  4. Else statement should not have parentheses.
  5. Required header files are missing.

Q3: Program to calculate the Average Price of Books (5 Marks)

Explanation:

The program should:

  1. Take price of books as input from the user.
  2. Add the prices together.
  3. Divide the total price by the number of books.
  4. Display the average price on the screen.

Q4: Find the output of the given program

Explanation:

The program checks a condition using an if statement.
If the condition is true, it prints a value and updates variables.
If the condition is false, the statements inside the block are not executed.

(Exact output depends on the correct variables used in the program.)


Q5: Write a program to find the product

Given expression:

Product = Number × 2⁵

Explanation:

The program should:

  1. Take number as input from the user.
  2. Calculate 2 raised to the power 5.
  3. Multiply the number by this value.
  4. Display the result.

Other Questions Asked in Different Midterm Papers

Q: Write the general syntax of a switch statement.

Answer:

A switch statement is used to select one option from multiple choices.
The program evaluates an expression and executes the matching case.
If none of the cases match, the default statement executes.


Q: What are application software? Give examples.

Application software are programs designed to help users perform specific tasks.

Examples:

  • Microsoft Word
  • Microsoft Excel
  • Web Browsers
  • Media Players

Q: What is call by value and call by reference?

Call by Value:
In call by value, a copy of the variable is passed to the function. Changes made inside the function do not affect the original variable.

Call by Reference:
In call by reference, the actual address of the variable is passed to the function. Changes made inside the function affect the original variable.


Q: What is the difference between while loop and do-while loop?

While Loop:

  • Condition is checked before executing the loop.
  • It may execute zero times.

Do-While Loop:

  • Condition is checked after executing the loop.
  • It executes at least one time.

Q: Why do we write comments in programs?

Comments are written to:

  • Explain the logic of the program
  • Make code easier to understand
  • Help other programmers read the code

Comments do not affect program performance.


Q: What are system software? Give examples.

System software are programs that control and manage computer hardware.

Examples:

  • Operating System (Windows, Linux)
  • Device Drivers
  • Compiler
  • Assembler

Q: What is an array?

An array is a collection of elements of the same data type stored in consecutive memory locations and accessed using an index number.


Q: What is a 2D array?

A two-dimensional array stores data in rows and columns similar to a table or matrix.


Q: What are relational operators?

Relational operators are used to compare two values.

Examples:

  • Greater than
  • Less than
  • Greater than or equal to
  • Less than or equal to
  • Equal to
  • Not equal to

Important MCQs that often appear in CS201 Midterm

  1. #include is called Preprocessor Directive
  2. Arrays store elements of same data type
  3. Loop is also called repetitive structure
  4. Continue statement moves to next iteration of loop
  5. Structure elements can be accessed using dot operator
  6. iostream library is used for input and output operations
  7. Analysis is the first step of program development
  8. Arrays are passed to functions by reference
Contents Copyrights Reserved By T4Tutorials