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

Assignment 2

This document outlines an assignment with 11 programming problems to be completed and submitted by September 30, 2016. The problems include: 1) printing an 8x8 checkerboard, 2) writing a program to calculate total resistance of parallel resistors, 3) converting numbers to words, 4) modifying the previous program to handle numbers up to 100, 5) writing a function to return the maximum value in an array, 6) writing a recursive function to count the number of times a number appears in an array, 7) writing a procedure to count the number of words in a string, 8) writing a function to check if one string begins another, 9) writing a function to generate a hash code by adding character values, 10) writing

Uploaded by

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

Assignment 2

This document outlines an assignment with 11 programming problems to be completed and submitted by September 30, 2016. The problems include: 1) printing an 8x8 checkerboard, 2) writing a program to calculate total resistance of parallel resistors, 3) converting numbers to words, 4) modifying the previous program to handle numbers up to 100, 5) writing a function to return the maximum value in an array, 6) writing a recursive function to count the number of times a number appears in an array, 7) writing a procedure to count the number of words in a string, 8) writing a function to check if one string begins another, 9) writing a function to generate a hash code by adding character values, 10) writing

Uploaded by

Monica Singh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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