The words you are searching are inside this book. To get more targeted content, please make full-text search by clicking here.
Discover the best professional documents and content resources in AnyFlip Document Base.
Search
Published by mas7720, 2019-12-03 03:22:51

exercisecplusplus

exercises C++

Keywords: exercisecplusplus

C++ Tutorial

For Foundation in Science and Technology (FiST) UniKL

KFP05202 Introduction To Computer Technology 2

Chapter 1

1. Define program

___________________________________________________________________________
___________________________________________________________________________

2. What is programming language?

___________________________________________________________________________
___________________________________________________________________________

3. State two (2) examples of programming language.

___________________________________________________________________________
___________________________________________________________________________

4. There are two (2) types of translator. List and briefly explain each of
them.

Types of Translator Explanation

1

Chapter 2

List examples of programming language and state the differences:

First Generation Language Second Generation Language

TYPES OF
LANGUAGE

Third and fourth Generation Fifth and future Generation
Language Language

2

Chapter 3
Introduction
List 6 steps to develop the system:

1. ____________________________________________________
2. ____________________________________________________
3. ____________________________________________________
4. ____________________________________________________
5. ____________________________________________________
6. ____________________________________________________

3

Problem Analysis and Program Modelling

1. Calculate area of square.

Input :

___________________________________________________________________________

Process :

___________________________________________________________________________

Output :

___________________________________________________________________________

Pseudo code Flow chart

4

2. Calculate the price of a car after 5% discount.

Input :
__________________________________________________________

Process :
__________________________________________________________

Output :
__________________________________________________________

Pseudo code Flow chart

5

3. A program is required to read two numbers from a user, multiply them
together, and print their result on the screen

Input :
___________________________________________________________

Process :
___________________________________________________________

Output :
___________________________________________________________

Pseudo code Flow chart

6

4. A program will read temperature value in Celsius. Convert the value and
give output in Fahrenheit. (formula : Fahrenheit = 1.8 x Celsius + 32.0)

Input :
___________________________________________________________

Process :
___________________________________________________________

Output :
___________________________________________________________

Pseudo code Flow chart

7

5. Program will convert value in Kilometre to Metre. The program will
accept the value in Kilometre from the user, and display the value in
Metre on the screen.

Input :
___________________________________________________________

Process :
___________________________________________________________

Output :
___________________________________________________________

Pseudo code Flow chart

8

Chapter 4

1. Program will read name and ICT mark of the students. If ICT mark is less
than 50, printout that student name and status “FAIL”.

Input :
___________________________________________________________

Process :
___________________________________________________________

Output :
___________________________________________________________

Pseudo code Flow chart

9

2. Program will read name and ICT mark of the students. If ICT mark is less
than 50, printout that student name and status “FAIL” else printout that
student name and status “PASS”.

Input :
___________________________________________________________

Process :
___________________________________________________________

Output :
___________________________________________________________

Pseudo code Flow chart

10

3. A program will read a temperature value in Celsius. If temperature is
more than 30, the message will be “Hot Day!”

Input :
___________________________________________________________

Process :
___________________________________________________________

Output :

___________________________________________________________________________

Pseudo code Flow chart

11

4. A program will read a temperature value in Celsius. If temperature is more
than 30, the message will be “Hot Day!” else the message will be “Cool
Day!”

Input :
___________________________________________________________

Process :
__________________________________________________________

Output :
___________________________________________________________

Pseudo code Flow chart

12

5. A program will read a temperature value in Celsius. If temperature is more
than 30, the message will be “Hot Day!”. If temperature (20 – 29) the
message will be “Good Day!” or else the message will be “Cool Day!”.

Input :
___________________________________________________________

Process :
___________________________________________________________

Output :
___________________________________________________________

Pseudo code Flow chart

13

6. A person can vote if meet the following criteria :
i) Malaysian citizen
ii) Age more than 20 years old
A program will represent whether the person is qualified or not to vote
based on the criteria. Print message “Qualified To Vote”.

Input :
___________________________________________________________

Process :
___________________________________________________________

Output :
___________________________________________________________

Pseudo code Flow chart

14

7. A person can vote if meet the following criteria :
iii) Malaysian citizen
iv) Age more than 20 years old

A program will represent whether the person is qualified or not to vote
based on the criteria. Print name and message “Qualified To Vote” else
print name and message “Not Qualified To Vote”.

Input :
___________________________________________________________

Process :
___________________________________________________________

Output :
___________________________________________________________

Pseudo code Flow chart

15

8. For question number two (2) please write a program for 10 students.

Input :
___________________________________________________________

Process :
___________________________________________________________

Output :
___________________________________________________________

Pseudo code Flow chart

16

9. For question number seven (7) please write a program for n persons.

Input :
___________________________________________________________

Process :
___________________________________________________________

Output :
___________________________________________________________

Pseudo code Flow chart

17

Chapter 5

Give the possible data type to represent the input from the user and the
output from the screen based on situation below:

Situation Data Type
Student enters their name to eKoq System

Teacher enters students mark to Ecitie

Malek keys in his worker’s salary for this month

Doctor Amira writes her patient’s phone number

Tauke Wong scans bar code from a packet of
goodies

ATM machine shows your balance on the screen

Puan Samsidar scans your matric card for returning
book at the library

18

Chapter 6 EVALUATE

1. Evaluate each of the following expression

EXPRESSION

(3<7) && (2<0) || (6==3+3)
((3<7) && (2<0)) || (6==3+3)
(3<7) && ((2<0) || (6==3+3))

!((-4.2 <3.0) && (10<20))
(!(-4.2 <3.0) ) ||(! (10<20))

2. Given integer variables x, y and z with values 10, 7, 2 respectively, determine
the value of each of the following arithmetic expressions.

ARITHMETIC EXPRESSION VALUE

x + 2*y – z
x / z – (x * x + y)

(x * y) % z
5 * (x + y + z) – x / z

x*y–x*z
y * (x + z) * (x – y)

19

3. Given the following declarations and initial assignments :
int i = 4, j = 21, k; float x = 94.55, y; char a = ‘z’, b = ‘t’,
c = ‘ ‘;

Determine the value of each of the following assignments :

ASSIGNMENT VALUE

k=i*j

y=x+i

y=k=j

a=b=c

i=i+j

j=k-5

20

21


Click to View FlipBook Version