Assignment 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:
[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]