466 Programming and Data Structures
9) Explain low level disk operations.
10) Explain command line arguments.
11) Explain Environment Variables.
12) How re-direction of input and output is done? Explain in brief.
B) Answ er the following b y selecting the appropriate option.
1) The f scanf () statements reads data from
a) file b) keyboard
c) both (a) and (b) d) none of the above
2) When f open () fails to open a file it returns
aO NULL b) -1
c) 1 d) none of the above
3) A file opened in w+ mode can be
a) read/write b) only read
c) only write d) none of the above
4) Command line arguments are used to accept argument from
a) command prompt of operating system b) through scanf () statement
c) both (a) and (b) d) none of the above
5) The redirection operator 1 > ' transfers any output to
a) text file b) console
c) both (a) and (b) d) none of the above
6) This function is used to detect the end of file
a) fe o f() b) ferrorO c) fputsO d) fgetchO
7) The EOF is equivalent to
a) -1 b) 0
c) 1 d) none of the above
C] Attenjpt the following programs.
1) Write a program to generate a data file containing the list of cricket players, no. innings played
highest run score and no. of hatrik made by them. Use structure variable to store the cricketer's
name, no.of innings played, highest run score & number of hatricks,
2) Write a program to reposition the file to its 10th character.
3) Write a program to display contents of file on the screen. The program should ask for file name.
Display the contents in capital case.
4) Write a program to find size of the file.
5) Write a program to combine contents of two files in a third file. Add line number at the beginning
of each line.
6) Write a program to display numbers from 1 to 100. Re-direct the output of the program to text file.
7) Write a program to write contents of one file in reverse into another file.
8) Write a program to interchange contents of two files.