Fungsi (ii)

1

Click here to load reader

Transcript of Fungsi (ii)

Page 1: Fungsi (ii)

FUNCTION BY VALUE

A stationary Company sells four types of items and each item price is shown in following table:-

Item Code Price per Quantity

1031 RM 1.23

3031 RM 2.34

2111 RM 6.78

3455 RM 8.75

a. Write a function definition to calculate the price for an item and display the result. This function

will receive two parameters which are item code and quantity for the item. The function

prototype for this function is declared as follows:-

void Price ( int, int);

b. If this function Price is declared as follows

float Price ( );

write the function definition whereby the data of an item code and quantity will be input this

function, then this function will calculate the price and return the result to the main.