Upload
atie-iekah
View
223
Download
0
Embed Size (px)
Citation preview
8/18/2019 Kuiz 4 .
1/2
UiTM (NEGERI SEMBILAN)
Quiz 5 – CSC 425Name: Matric N:
QUESTION 1 (Final Oct 2010)
a) Write a function definition to calculate how much Malaysian Ringgit would be required toexchange either into US Dollar, Euroean Euro or U! "#$% &he function has the following rototye' ( mar*s)
double buy_currency(int, double);
&he first arameter is for the tye of currency where the numbers +, , - would be used to reresent the Dollar,Euro and "#$ resecti.ely%
&he second arameter would be the amount of money to be exchanged%
&he function would return the amount of Malaysian Ringgit%
/ou are gi.en the following exchange rate'(Dollar) 0+ 1 RM-%2%(Euro)3+ 1 RM4%5("#$)6+ 1 RM4%74
Tip/Hint:- double buy_currency(int type of currency, double amount of money to be exchanged){ If (type of currency ==1) amount of Malaysia Ringgit = !"# $ amount of money to be exchangedelseif %%
return amount of Malaysia Ringgit &
b) Write another function definition to dislay the amount in Malaysian Ringgit and the amount of the exchanged currency%&his function will accet two arameters which are the amount of Malaysian Ringgit and the amount of the exchangedcurrency% &he function has the following rototye' (- mar*s)
void display_currency(double, double);
Tip/Hint:-
'oid display_currency(double amount of Malaysia Ringgit, double amount to be exchanged){ utput amount of Malaysia Ringgit%%%utput amount to be exchanged
&
c) Write a main rogram that will inut the tye of currency and the amount of money% &herogram would call all of the function abo.e to exchange and dislay the Malaysia Ringgit currency into the desiredcurrency that the user has chosen% (2mar*s)
Tip/Hint:- *oid main( )
{ %!Input type of currency Input amount of money to be exchange+all function buy_currency +all function display_currency %!!
&
1 Noth/quiz4csc425
8/18/2019 Kuiz 4 .
2/2
OR QUESTION 2 – ARRAY (APRIL 2011)
Write a 899 rogram that romts the user to enter a sequence of letters% Store the characters in an array named l e t t er s with +: elements% &his rogram will determine whether a letter is a .owel or a consonant% &hen, reare a frequencytable to show the number of .owels and consonants in that array% &he details of the rogram are exlained as follows'
a) Write a function to inut the sequence of letters% &he function head is'void inputLetters (char l e t t e r s [ 1 0 ]) (- mar*s)
Tip/Hint-
Void InputLetters(char letter[10])
{
For (int i=0 i!10 i"")
Input into letters[i]
#
b) Write a function to determine whether the letter is a .owel or consonant% &hen, count the frequency of .owel andconsonant% &he function head is'
void determineLetters (char letters[10], int &vowel, int &consonant) (; mar*s)
Tip/Hint-
Void deter$ineLetters(char letter[10]% int &'oel% int &consonant )
{ For (int i=0 i!10 i"") I letter[i] == *a+ or *e+ or *I+ or *o+ or *u+ count re,uenc 'oel
.lse count re,uenc consonant #
c) Write a function to dislay the frequency table as shown below' (4 mar*s)
&he letters are' thedog