Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Assignment 2

Total marks 60
submission date 30 sep 2016
1. Print a checker board (8-by-8 grid). Each square should be 5 -by-3 characters wide.
[5]
2. The total resistance of n resistors in parallel is:

Suppose we have a network of two resistors with the values 400 and 200 .
Then our equation would be:
Substituting in the value of the resistors we get:

So the total resistance of our two-resistor network is 133.3 .


Write a program to compute the total resistance for any number of parallel resistors.
[10]
3. Write a program that converts numbers to words. For example, 895 results in "eight nine
five."
[5]
4. The number 85 is pronounced "eighty-five," not "eight five." Modify the previous
program to handle the numbers through 100 so that all numbers come out as we really say
them. For example, 13 would be "thirteen" and 100 would be "one hundred." [5]
5. Write a function that returns the maximum value of an array of numbers.

[5]

6. Write a function count(number, array, length) that counts the number of times number
appears in array. The array has length e lements. The function should be recursive. Write
a test program to go with the function.
[5]
7. Write a procedure that counts the number of words in a string. Write a program to test
your new procedure.
[5]
8. Write a function begins(string1,string2) that returns true if string1 begins string2. Write a
program to test the function.
[5]

9. Write a function that takes a character array and returns a primitive hash code by adding
up the value of each character in the array.
[5]
10. Write a function that scans a character array for the character and replaces it with _.
[5]
11. Write a function that takes a single string as its argument and returns a pointer to the first
nonwhite character in the string.
[5]

You might also like