0% found this document useful (0 votes)
18 views

Lab 1 CSC128

Uploaded by

Aidil Aiman
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

Lab 1 CSC128

Uploaded by

Aidil Aiman
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

CSC128

Lab 1

Name:
Matric No:
Group:
Date:

Instuction: Write pseudocode for problems below. Upload to google classroom if finish.

Problem 1:
To determine either a number is odd or even

Analyse

Output:
Input:
Process:

Pseudocode

BEGIN
DECLARE int number
INPUT number
if (number % 2 == 0)
OUTPUT number is even
else
OUTPUT number is odd
END

C++ Program

#include <iostream>

using namespace std;

int main()

{
int number;
cout<< "Enter a number: " ,
cin >> number,
if (number % 2 == 0 )
cout << number << "is even",
else

1
cout << number <<"is odd ",
return 0,
}

Screen Output

Problem 2:
To determine the higher between two numbers

Analyse

Output:
Input:
Process:

Pseudocode

BEGIN
DECLARE int number1, number2
INPUT number1, number2
if (number1 > number2)
OUTPUT number1 is higher
else
OUTPUT number2 is higher
END

C++ Program

Screen Output

2
Problem 3:
Enter height in meter and display height in feet.

Analyse

Output:
Input:
Process:

Pseudocode

BEGIN
DECLARE double meter, feet
INPUT meter
CALCULATE feet = meter * 3.28
DISPLAY feet
END

C++ Program

Screen Output

Problem 4:
To calculate perimeter and area of rectangle

Analyse

Output:
Input:
Process:

3
Pseudocode

C++ Program

Screen Output

Problem 5:
Ask user for a weight, you need to convert the weight to pound and display it. Hint 1 kg = 2.2
pounds.

Analyse

Output:
Input:
Process:

Pseudocode

C++ Program

Screen Output

Problem 6:
Convert miles into kilometres and metres. User need to input distance in miles and find the
distance in kilometres and metres.

4
Hint:
1 miles = 1.609 kilometers.
1 miles = 1609 metres

Analyse

Output:
Input:
Process:

Pseudocode

C++ Program

Screen Output

Problem 7:
Write a C++ program that asks the user to enter a number of 10 cents and a number of 50 cents
syilling. The program will calculate and output the total of cents entered.

Sample Output

Enter a number of 10 cents: 10


Enter a number of 50 cents: 3

Total cents: 250


Total: RM2.50

Analyse

Output:
Input:
Process:

Pseudocode

5
C++ Program

Screen Output

Problem 8:

Four workers were responsible to pluck oranges. The owner of the orange farm will be given 40%
of the oranges. The workers share equally the balance of the oranges. The balance of oranges after
divided will be used to make juice. Write a complete program that accepts input for the amount of
oranges that were plucked. You are also required to calculate and print amount of oranges that
were received by the owner, each of the workers and balance of oranges to make juice.

Sample Output

Enter number of oranges plucked: 125


Total oranges for the owner is 50
Total oranges for each worker is 18
Balances of oranges to make juice is 3

Analyse

Output:
Input:
Process:

Pseudocode

C++ Program

Screen Output

6
Problem 9:

Write a program that calculates and displays the cost to cut the grass in the yard of the following
house. The rate charged is RM2.50 per square meter. The input values are length and width of the
house and the yard.

Analyse

Output:
Input:
Process:

Pseudocode

C++ Program

Screen Output

You might also like