0% found this document useful (0 votes)
12 views

Programming Assignment Unit7 (1)

Uploaded by

stookslexi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Programming Assignment Unit7 (1)

Uploaded by

stookslexi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

CISC131 Programming assignment Unit 7

20 points for each question

1. Design a function that recursively displays string ‘hello world’ n times,


n is the argument.

2. Design a recursive function that accepts an integer argument, and


prints the numbers 1 up through n.

3. Design a recursive function that accepts two arguments into the


parameters x and y. The function should return the value of x times y.
Remember, multiplication can be performed as repeated addition as
follows:
7*4=4+4+4+4+4+4+4

4. Design a function that accepts an integer as argument and returns the


sum of all the integers from 1 up to the number passed as an
argument. For example, if 50 is passed as an argument, the function
will return the sum of 1,2,3,4… 50. Use recursion to calculate the sum.

5. Design a function that uses recursion to raise a number to a power.


The function should accept two arguments: the number to be raised,
and the exponent. Assume the exponent is a nonnegative integer.

You might also like