- HW№12(due date is Wednesday, May 7th)-
Last homework assignment:
Write a program that will read-in four words (from the keyboard, one by one; user may enter a sentence of any length and your program will take only first four words), then it should:
1. output the length of each word.
2. concatenate these words, putting two *'s between them (and no spaces).
3. compares consecutive pairs of words to check if they are equal.
2 examples of the program's run:
1. input: Hello hello how are you
output: length of the first word is 5, length of the second word is 5, length of the third word is 3, length of the fourth word is 3.
result of the concatenation with *'s: Hello**hello**how**are
There are no two equal consecutive words.
2. input: Hello my my name is Elizabeth
output: length of the first word is 5, length of the second word is 2, length of the third word is 2, length of the fourth word is 3.
result of the concatenation with *'s: Hello**my**my**name
Second and third words are equal. - HW№11(due date is Monday, April 21st):
1. Write a program that will copy all the information from one file to the file copy-of-input.dat. User should be asked for the input file name (it should be an existing file and it should contain something). Your program should copy everything (symbol by symbol) from this file to the file copy-of-input.dat
2. Write a program that will do a search for a value in an array of 12 elements.
Comments:
1. The array consists of 12 elements
2. User inputs the values of elements
3. User inputs the value to be searched for in the array
4. Program searches the array and outputs the index of an element which is the one we are looking for. If array doesn't have such number, the program should output: "No such number in the array".
3. Modify the program 2 so that the size of the array is not known in advance (the user will enter the size of the array)
- HW10 (due date is Wednesday, April 9th):
Write a program that will do the following:
- asks a file name (for the input stream)
(don't forget to check for existance of the file)
- reads all the numbers from that file and finds the largest number
(it should read in all values untill it reaches the end of the file – see member function eof)
- appends the result to the output file output.dat
User should be able to run the program as many times as user wants (user should also be asked an input file name for each run/iteration) - HW9 (due date is Monday, April 7th):
Write a program that:
- reads in 6 numbers from a file (you can choose any file name, e.g. ''infile.dat'' or ''in.dat''), then
- prints them out to screen, and
- finds their product and outputs the result into an output file with any name (e.g. ''output.dat'') - HW8 (due date is Wednesday, April 2nd):
p.293 / 1 - HW7 (due date is Monday, March 31st):
Write functions that find the average of three numbers the average of four numbers, the largest of three numbers and the largest of four numbers. Then write a program that does the following:- The program should ask the user to enter the number of values he/she wants to work with (so the user enters either 3 or 4).
- Then the program should ask to enter those numbers.
- Then the program finds the average of those numbers, the largest of those numbers and displays them on the screen.
- HW6 (due date is Wednesday, March 26th):
page 244 / 9
with the following modification:
constant 2.9 from the Hat size formula should be declared as global constant and used to find Hat size.
- HW5 (due date is Monday, March 10th):
Write a program that outputs N first Fibonacci numbers. N is entered by the user.
(you can read about Fibonacci numbers on page 175, in project number 10)
Read section 3.4 Designing Loops - HW4 (due date is Wednesday, March 5th):
page 171/ 1,
program 2: Write a program that for two decimal numbers n and m (n>=m) find how many m's fit into n (i.e. how many times m can be substracted from n). Don't use division for it. Use while or do-while loop-mechanism. Your program should ask the user to input n and m. - HW3 (due date is Monday, February 25th):
pp.104-105/ 1,6 - HW2 (due date is Wednesday, February 13):
p. 37/ 7,8 - HW1 (due date is Monday, February 11):
Write a program that finds the average of three numbers and the product of three numbers. Numbers are real numbers. Your program should take the data from the standard input. You should declare five variables in your program (three for numbers from the input, one for the average and the other for the product). Results of average and product should be stored in corresponding variables, and then, displayed on the screen.