CS19002 Programming and Data Structures Laboratory Spring 2009, Section 2

## Assignment 5(Arrays)

This assignment is an extension of Assignment 4. In this assignment, you print all the ways of eating m idlis in n. Follow the same recursive strategy as described in connection with Assignment 4. Use an array to store the choices of the numbers of idlis eaten on different days. Print the array on (or after) Day n. Also, keep a counter to number the different choices. The array and/or the count may be maintained as global variables or passed as parameter(s) to the recursive function --- the choice is left to you.

### Part 1 (Credit: 70%)

You have to eat at least one idli per day, and a whole number of Idlis on each day. There is no upper bound on the number of idlis you may consume on a day.

### Part 2 (Credit: 30%)

Use the additional restriction that you are allowed to eat at most B idlis on a day.

Report the output of your program for the following two inputs.

```   m = 10, n = 3, B = 4
m = 13, n = 10, B = 2
```

Your output should look like the following.

```   Number of Idlis (m)    : 5
Number of days (n)     : 3

Part 1:
Choice 1: 1+1+3
Choice 2: 1+2+2
Choice 3: 1+3+1
Choice 4: 2+1+2
Choice 5: 2+2+1
Choice 6: 3+1+1

Part 2:
Max Idlis per day (B)  : 2
Choice 1: 1+2+2
Choice 2: 2+1+2
Choice 3: 2+2+1
```

Submission site | Lab home | Course home | My home