Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

Arab Academy for Science, Technology & Maritime

TransportCollege of Engineering and Technology


ECE2102 Applied Programming

Week 5 - Pointers

1. Trace the following questions


a.

b.

c.
d.

e.

f.

g.
h.

2. zeroIt is a function that takes one argument and returns no


value. The argument is a pointer to int. The function stores the
value 0 back into the variable pointed to by the argument.

x is an int variable that has been declared. Write a statement that


sets the value stored in x to zero by invoking the function zeroIt.

3. Write a function that takes two arguments of type int. the


function should calculate the quotient and remainder of dividing
the first argument by the second argument. The function does not
return a value.

You should write a program that reads x and y from the user, and
include a statement that sets the value of q to the quotient of x
divided by y, and sets the value of r to the remainder of x divided
by y, by calling the above function.
4. 1-minMax is a function that takes five arguments and returns
no value. The first three arguments are of type int. The last two
arguments are pointers to int that are set by the function to the
largest and smallest of the values of the first three
parameters, respectively. big and small are two int variables that
have been declared in the main function. Write a program that
scans x,y,z and sets the value of big to the largest of x, y, z and
sets the value of small to the smallest of x, y, z by calling
minMax.

5. Write a program for an automatic teller machine that


dispenses money. The user should enter the amount desired (a
multiple of 10 dollars) and the machine dispenses this amount
using the least number of bills. The bills dispensed are 50s, 20s,
and 10s. Write a function that determines how many of each
kind of bill to dispense.

Example:
Enter amount to withdraw:130
Number of 50:2

Number of 20:1
Number of 10:1

You might also like