The language was formalized in 1988 by the American National Standard Institue (ANSI)

computer science

Description

Ø  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.

Rule:
The file name should be sample.txt.

Input format:
Give the input as a file which contains the integer values.

Output format:
The output will be the integer which is the sum of the integers. Display the output in the console.

Sample Input file (sample.txt):
1
2
3
4
5

Sample Output:
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 format:
Input is a file. Filename: input.txt

Output format:
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
Structured language
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

 



Related Questions in computer science category