0% found this document useful (0 votes)
21 views5 pages

Pseudocode

Uploaded by

redunikorn
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)
21 views5 pages

Pseudocode

Uploaded by

redunikorn
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/ 5

Pseudocode

1.0 Start

2.0 Call input function


2.1 Read distance in miles (M)
2.2 Return M

3.0 Call process function


3.1 Calculate distance in kilometer (K= M x 1.609)
3.2 Return K

4.0 Call output function


4.1 Display the distance in kilometers (K)

5.0 End

11
b) Flow Chart: Basic Symbols Represent
Various Operation
Direction Preparation

Terminal –
Process
beginning / end

Decision Input /
Output

Connector
Predefined Process
(Subroutine)

12
Flow Chart
Input () Process (M)

Start
Read distance
in miles (M) K = M * 1.609

M = Input() Return Return


M K

K = Process(M) Output (K)

Display distance
in kilometers (K)
Output(K)

Return
End
13
3. Develop (or write) the program:
//written by: Nuridawati Mustafa Comments
/* Problem Solving Exercise : Introduction
to C++ */
#include <iostream> Preprocessor directives
using namespace std; Namespace
Global
double input(); //global declaration Declaration
void display(double K);
Area
double calculate(double M);

void main()
{
double M, K; //local declaration
//M represents distance in miles
//K represents distance in kilometers Main Function

M = input();
K = calculate(M);
display(K);
}
14
double input()
{
double miles;
User-
cout<<"Please enter distance in miles :";
Defined
cin>>miles;
Function
return miles;
}

double calculate(double distance_in_miles)


{
double km; User-
km = distance_in_miles * 1.609; Defined
return km; Function
}

void display(double distance_in_km) User-


{ Defined
cout<< "Distance in kilometre is "<< distance_in_km;Function
cout<< "\n";
}
15

You might also like