You are on page 1of 8

CSC425 INTRODUCTION TO COMPUTER PROGRAMMING

Exercise 3
Learning Outcomes
After completing this lab, you will be able to: o describe the steps in
the programming process o know how to edit a program o know
how to compile and run a program

A. LAB ACTIVITIES
Question 1
List the five basic steps in the programming process.

Answer 1. Defining the problem 2. Planning the solution 3. Coding the program 4.
Testing the program 5. Documenting the program

Question 2
Define an algorithm.

Answer A precise step-by step action to perform overall task of the program

Question 3
Define a flowchart.

Answer A flowchart is a type of diagram that represents an algorithm, workflow or


process.

Question 4
Define a pseudocode.

Answer Pseudocode is a detailed yet readable description of what a computer program


or algorithm must do, expressed in a formally-styled natural language rather than in a
programming language.

Question 5
What is the purpose of documentation inside a program?

1
CSC425 INTRODUCTION TO COMPUTER PROGRAMMING

Answer The presence of documentation helps keep track of all aspects of an application
and it improves on the quality of a software product.

Question 6
What is the symbol used to represent input/output in a flowchart?

Answer Parallelogram

Question 7
Ammar lives in Shah Alam that charges 3% income tax on yearly wages. He wants you
to write a program that will display the income tax. Identify the input, process and output
of this problem.

Answer
Input: scan the yearly wages
Process: calculate yearly wages*0.03=income tax
Output: Display the income tax

Question 8

Edit your program according to the following program statements. Save your program
as lab1_prog3.cpp.

Program 1.3

a. Compile the program. If error messages appear, write down all the errors.
‘cout’ was not declared in this scope
‘endl’ was not declared in this scope

b. Check your program carefully. Compile and run the program again until no
errors appear. What is the program output?

2
CSC425 INTRODUCTION TO COMPUTER PROGRAMMING

Question 9

Edit Program 1.3 by changing Hello and world to your name and student ID, save
your program as lab1_prog4.cpp. Compile and run after the modification.

a. What is the output?

b. What is the purpose of cout command in this program?


To display name and student ID.

3
CSC425 INTRODUCTION TO COMPUTER PROGRAMMING

Question 10

Type the following program statements. Save your program as lab1_prog5.cpp.


//Program Name: lab1_prog5.cpp
//This program is to display a value
#include <iostream>
using namespace std;

int main()
{
cout << (14 + 4 – 8 / 2) << endl;
return 0;
}
Program 1.4

a. Compile and run the program. What is the output?

b. What is the purpose of cout command in this program?


To display the total of calculation.

Question 11

Type the following program statements. Save your program as lab1_prog6.cpp.

4
CSC425 INTRODUCTION TO COMPUTER PROGRAMMING

//Program Name: lab1_prog6.cpp


//This program is to display message and value
#include <iostream>
using namespace std;

int main()
{
cout << “5 + 2 = ” << (5 + 2) << endl;
return 0;
}
Program 1.6

a. Compile and run the program. What is the output?

5
B. POST-LAB ACTIVITIES
Question 1

Write a program to display output as below:

* * * * * * * * * * * * * *
* * * * *
* Thank You *
* Please come again.
* * * * * * * * * * * *
* * * * * *

Question 2

Write a program to display your name, address and telephone number.


6

Question 3

Write a program to display your own message. Your message must be at least five lines.
7

You might also like