Ø Consider an input file
"sample.txt" with integer values. Write a program to open the file
and read the content to find the sum of all values in the file.
The file name should be sample.txt.
Give the input as a file which contains the integer values.
The output will be the integer which is the sum of the integers. Display the output in the console.
Sample Input file (sample.txt):
The sum of the integers in the file sample.txt is:15
Ø Write the program to
open an input file and read the number of lines in the input file.
Input is a file. Filename: input.txt
The output will be the integer which is the number of lines in the file. Display the output in the console.
Sample Input file (input.txt):
C was invented to write an operating system called UNIX.
C is a successor of B language which was introduced around 1970
The language was formalized in 1988 by the American National Standard Institue (ANSI).
By 1973 UNIX OS almost totally written in C.
Today C is the most widely used System Programming Language.
Most of the state of the art software have been implemented using C.
Easy to learn
It produces efficient programs.
It can handle low-level activities.
It can be compiled on a variety of computers.
Sample Output 1:
The file has 11 lines