EXAMSHARE

Western Delta University, Oghara Delta State

department of computer science
college of computing
western delta university

first semester examination 2022/2023 session

CSC203 - computer programming II time: 2hrs: 30mins

answer four (4) questions


  1. Question 1

    1. Briefly define the following:
      1. Whitespace
      2. Constants
      3. Header files
      (4.5 marks)
    2. Write a C++ program that displays "Welcome to C++ Programming!" and "Computer Programming is an interesting endeavor!" (3 marks)
    3. Consider the following C++ program and use it to answer the question that follows:
      // This program computes the area of a circle
      #include <iosteam>
      #include <cmath>
      using namespace std
      int main ()
      const float pi = 3.142;
      double radius, result, area, exponent = 2.0;;
      cout >> "Enter the value of radius" >> endl;
      cin << radius;
      Result = power(radius, exponent);
      cout >> "The area of the circie is " >> area;
      return 0;
      }
      Identify and correct at least ten (10) syntax errors in the given program (10 marks)
  2. Question 2

    1. Define the following programming terms:
      1. comment
      2. setw manipulator
      3. variable name
      4. increment operator
      5. decrement operator
      (7.5 marks)
    2. Give six (6) examples of valid variable names in C++ programming. (3 marks)
    3. Suppose total_tax = avg_ _Tax * ++count; explain how a C++ compiler will execute the given statement (3 marks)
    4. Write a C++ program that generates the table below
      YearProfit
      1950500000000
      1951600000000
      1952700000000
      (4 marks)
  3. Question 3

    1. Using suitable examples, write explanatory notes on the following:
      1. Relational operators
      2. Loops
      (4 marks)
    2. Give the syntax of while and do loops (4.5 marks)
    3. Name four (4) arithmetic operators and describe them using examples (4 marks)
    4. Write a C++ program using a while loop that asks a user to enter numbers, calculates their sum, prints the result until the number entered is negative (5 marks)
  4. Question 4

    1. Highlight the role of decisions in computer programming (2 marks)
      1. With the aid of a flowchart only, describe the working principle of if...else statement (3.5 marks)
      2. Write down the syntax of a switch statement (4 marks)
    2. State three (3) examples of logical operators and show how they are represented in C++ (3 marks)
    3. Write a C++ program that obtains test score and assigns grade according to the following information. The test score is an integer from 1 to 100
      Test ScoreGrade
      70 and aboveDistinction
      60 - 69Merit
      50-59Pass
      Below 50Fail
      (5 marks)
  5. Question 5

    1. What is a Structure? (2.5 marks)
      1. State the syntax of a structure (3 marks)
      2. Write a program that defines a structure, assigns values to the structure and displays the values (5 marks)
      1. Define Enumeration (2 marks)
      2. Give the syntax of enumeration and write an enumeration whose values are months of the year (5 marks)
  6. Question 6

    1. Define a function (2 marks)
      1. Give two (2) reasons for using functions in computer programming (2 marks)
      2. What is an argument? (2 marks)
      3. Name three (3) parameter passing techniques to functions (3 marks)
      1. Define recursion (2 marks)
      2. Write a recursive function that adds a range of numbers by adding two numbers each time it is called by a main program (6 marks)