LearnFrenzy
Sign in Take a free test

C Input / Output · Exercise 4 of 4

C Input / Output Input/Output Programs

  • 8 questions
  • Page 1 of 1
  • Answers explained
0Attempted
0Correct
0Wrong
Directions

Programs that read input and work with files. Write each one yourself first, then open the solution – every solution was compiled and run with the input shown, and the output is the real output.

Question 1 Easy

Print a bill with left-aligned item names, right-aligned quantities and prices with two decimals, and a total line.

Question page & discussion
Question 2 Medium

Read a positive integer with scanf. On invalid input, discard the rest of the line and ask again. Print its square at the end.

Question page & discussion
Question 3 Medium

Read lines of the form name,age,score, parse each with sscanf, report lines that do not match, and print the average score.

Question page & discussion
Question 4 Medium

Read all input with getchar() and print how often each letter occurs (ignoring case), for letters that appear at least twice.

Question page & discussion
Question 5 Medium

Write three students' marks in three subjects to a file with fprintf, then read the file back with fscanf and print each total and the class topper.

Question page & discussion
Question 6 Hard

Store account balances as binary records, then change the balance of the second record in place (seek, read, seek back, write) and list all records.

Question page & discussion
Question 7 Hard

Find the size of a file with fseek and ftell, then print its characters from the last to the first by seeking backwards.

Question page & discussion
Question 8 Medium

Write two log lines, then add more at the end in two separate passes (as appending does), and print the file with line numbers. Use a temporary file.

Question page & discussion
All exercises doneBack to C Input / OutputRevise the concepts or pick another topic

Ready to test your Programming?

Timed online tests with instant scores and explanations.

Search LearnFrenzy

Esc

Quick links