Prob11 15

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 6

PROBLEM 11 - 15

Intermediate programming
PROBLEM11.CPP

•Write a program that reads a file


containing floating-point numbers. Print
the average of the numbers in the file.
Prompt the user for the file name.
PROBLEM12.CPP
• Write a program that reads each line in a file, reverses its characters, and
writes the resulting line to another file. Suppose the user specifies input.txt
and output.txt when prompted for the file names, and input.txt contains the
lines
Mary had a little lamb
Its fleece was white as snow
And everywhere that Mary went
the lamb was sure to go.
• After the program is finished, output.txt should contain
bmal elttil a dah yraM
wons sa etihw saw eceelf stI
tnew yraM taht erehwyreve dnA
.og ot erus saw bmal ehT
PROBLEM 13.CPP
• Write a program that will search a file of numbers of type int and
write the largest and the smallest numbers to the screen. The file
contains nothing but numbers separated line breaks.
PROBLEM14.CPP
• Write a program that merges the numbers in two files and writes all
the numbers into a third file. Your program takes input from two
different files and writes its output to a third file. Each input file
contains a list of numbers of type int in sorted order from the
smallest to the largest. After the program is run, the output file will
contain all the numbers in the two input files in one longer list in
sorted order from smallest to largest. Your program should define a
function that will sort the values of the two input files.
PROBLEM15.CPP
• Write a program to compute numeric grades for a course. The course
records are in a file that will serve as the input file. The input file is in
the following format: Each line contains a student’s last name, then
one space, then the student’s first name, then one space, then ten
quiz scores all on one line. The quiz scores are whole numbers and
are separated by one space. Make a list of 10 students in the input
file. Your program will take its input from this file and send its output
to a second file. The data in the output file will be the same as the
data in the input file except that there will be one additional number
(of type double ) at the end of each line. This number will be the
average of the student’s ten quiz scores. Write a function that
computes the average of each individual student.

You might also like