0% found this document useful (0 votes)
13 views1 page

01 Lab - Formatted File Streams

The document outlines a lab assignment for a Data Structures and Algorithms course, consisting of four programming tasks in C++. Each task involves creating, reading, and processing student records and quiz scores using C++ programs, with specific input and output formats provided. Students are required to complete the tasks individually and demonstrate their work to the instructor for credit.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views1 page

01 Lab - Formatted File Streams

The document outlines a lab assignment for a Data Structures and Algorithms course, consisting of four programming tasks in C++. Each task involves creating, reading, and processing student records and quiz scores using C++ programs, with specific input and output formats provided. Students are required to complete the tasks individually and demonstrate their work to the instructor for credit.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Spring 2023 BSF21 (CS/IT)

Data Structures and Algorithms Lab


Lab 01 Marks 05
Instructions
Work on this lab individually. You can use your books, notes, handouts etc. Program the following tasks in C++ compiler and then
compile and execute them. Show your work to the instructor before leaving the lab to get some or full credit.
Task 01
Write a program that creates a file named student.txt the program then lets the user enter a series of records consisting of students’
roll number, first name, last name and marks to be stored in the file (student.txt) separated by blank space on each new line. The
program should stop taking more data when user enters -999 as roll number.
Task 02
Write a program that opens the file created in Task 01, read all the records, and display them on the screen in exactly the following
format
Sample Execution
Roll No. Name Marks
1 Ali Imran 75
2 Asif Ali 87
3 Naveed Aslam 56
4 Shahid Farid 100
5 Hassan Khan 98
Name must contain the first name and last name of the student.
Task 03
Write a program to compute numeric grades for a course. The course records are in a file named input.txt (given with this lab’s
folder) that will serve as the input file. The input file is in exactly the following format: Each line contains a student’s; roll number,
then one space then ten quiz scores all on one line. The quiz score are whole numbers and are separated by one space.
Your program will take its input from this file (input.txt) and send its output to the console. The data displayed on the console
should be same as of the data in the input file except that there will be one additional number (of type int) at the end of each line.
This number will be the highest score of the student’s ten quiz scores.
Sample input
101 2 1 4 5 3 0 6 4 7 9
104 0 3 1 8 7 0 6 7 0 12
103 2 1 2 3 0 5 8 7 0 9
Sample output
101 2 1 4 5 4 0 6 4 7 3 7
104 0 3 12 8 7 0 6 7 0 1 12
103 2 1 2 3 0 5 9 7 0 8 9
Task 04
Write a program to determine the best two quizzes’ marks of a student, which are present in an input file and write the result to an
output file.
The input file “input.txt” (given with this lab’s folder) will contain several test inputs and is in exactly the following format: Each
line contains a student’s; roll number, then one space then ten quiz scores all on one line. The quiz score are whole numbers and
are separated by one space.
Your program should take its input from this file (input.txt) and send its output to the output file (output.txt). Each line in the output
will contain the roll number of a student followed by the marks of his/her best two quizzes in decreasing order.
Sample input
101 2 1 9 5 3 0 7 4 6 4
104 0 3 12 8 7 0 6 7 0 1
103 2 1 2 3 0 5 8 7 0 9
Sample output
101 9 7
104 12 7
103 9 8

☺ ☺ ☺ BEST OF LUCK ☺ ☺ ☺
Umair Babar, FCIT – PU. Lahore. Page 1 of 1

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy