Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
16 views2 pages

Tutorial Topic 2

The document presents a programming tutorial focusing on identifying logic errors in sample C++ code and correcting them. It includes tasks such as designing a flowchart and writing a complete program for data processing related to employee information. Additionally, it outlines the requirements for a program to summarize employee salary information and the necessary data for registration.

Uploaded by

amirdanial703
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

Tutorial Topic 2

The document presents a programming tutorial focusing on identifying logic errors in sample C++ code and correcting them. It includes tasks such as designing a flowchart and writing a complete program for data processing related to employee information. Additionally, it outlines the requirements for a program to summarize employee salary information and the necessary data for registration.

Uploaded by

amirdanial703
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

TutorialTopic 2(2)

SEQUENCE STRUCTURE

Question 1:

a) Find at least TWO logic errors in the following program :

#include <iostream.h>
void main()
{
int total, num1;
cout << “Please enter a number : “;
cin >> num1;
total = total + num1;
cout <<”\n Please enter another number :”;
int num2;
cin >> num2;
total = total + num1;
float average = total/2;
cout << “\n The average of the two numbers is “<<average <<’\n’;
}

b) Identify the errors, if any, in the following program.

i. void main() ii. void main()


{ {
int x, y; int p, q, sum;
cout << “Enter the value of x and y ‘; p = q = 10;
cin >> x, y; sum + 1 = p * q;
cout >> “The sum is “ << sum;
} }

iii. void main() iv. void main()


{ {
char x, y; int a, b;
x = 5; cout << “Enter two number ‘;
y = “siapa”; cin >> a, b;
cout << x << y; cout << “The sum is “ << a + b;
} }
Question 2:

a) Design a flowchart to represent Step 1 –Step 3 below.

b) Write a complete program to allow the following data processing:

i. Declare the variables (name, program code, part, CGPA).


ii. Ask the user the data of name, program code, part, and CGPA.
iii. Display the data in a proper format.

Question 3:

Company ABC Sdn Bhd is planning to develop a program to summarize their employees’
salary information. Each of the employee is required to register the name, IC number, ID
number (in format 123456) and salary data. Identify the data needs for the program.
Design the simple flow to allow the registration process for one employee. And finally
deploy your analysis and design to build a complete program.

You might also like