Read the second integer a character at a time; skip over any leading non-valid (i.e. not a digit between zero and ``base-1'') characters, then read valid characters until an invalid one is encountered.
Input Output ========== ====== 10 1234 1234 8 77 63 (the value of 77 in base 8, octal) 2 1111 15 (the value of 1111 in base 2, binary)The base will be less than or equal to 10.
NOTE: The Ceilidh skeleton is a complete program which works for the fixed base 10.
(unit4:loops:ai1)
a capital sum (integer number of pence),
a rate of interest in percent (float),
and a number of years (integer).
Compute the values of the capital sum with compound interest added over the given period of years. Each year's interest is calculated as
interest = capital * interest\_rate / 100;and is added to the capital sum by
capital += interest;Print out money values as pounds (pence / 100.0) accurate to two decimal places.
Print out a floating value for the value with compound interest for each year up to the end of the period.
Print output year by year in a form such as:
Original sum 30000.00 at 12.5 percent for 20 years Year Interest Sum ----+-------+-------- 1 3750.00 33750.00 2 4218.75 37968.75 3 4746.09 42714.84 4 5339.35 48054.19 5 6006.77 54060.96 6 6757.62 60818.58 7 7602.32 68420.90 8 8552.61 76973.51 9 9621.68 86595.19 10 10824.39 97419.58
(unit4:loops:int)
Typical output might be:
Inital value is 9 Next value is 28 Next value is 14 Next value is 7 Next value is 22 Next value is 11 Next value is 34 Next value is 17 Next value is 52 Next value is 26 Next value is 13 Next value is 40 Next value is 20 Next value is 10 Next value is 5 Next value is 16 Next value is 8 Next value is 4 Next value is 2 Final value 1, number of steps 19If the input value is less than 1, print a message containing the word
Errorand perform an
exit( 0 );(unit4:loops:hal)
Then print out the number of occurrences of each of the vowels a, e, i, o and u in the text, the total number of letters, and each of the vowels as an integer percentage of the letter total.
Suggested output format is:
Numbers of characters: a 3 ; e 2 ; i 0 ; o 1 ; u 0 ; rest 17 Percentages of total: a 13%; e 8%; i 0%; o 4%; u 0%; rest 73%Read characters to end of data using a construct such as
char ch; while( ( ch = getchar() ) >= 0 ) { /* ch is the next character */ .... }to read characters one at a time using getchar() until a negative value is returned.
(unit4:loops:lvc)
For end-of-data, the program loop should read until "getchar" delivers a value <= 0. When typing input, end the data by typing the end-of-file character, usually control-D. When reading from a file, "getchar" will deliver a negative value when it encounters the end of the file.
Typical output might be
Read a file of English text and print it out oneetc.
(unit4:loops:wds)