CSC 001: Introduction To Computer Programming 2015-Jan-May Semester Lab 8 (Deadline: Sunday, 5 April)

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

CSC 001: Introduction to Computer Programming

2015-Jan-May Semester
Lab 8 (Deadline: Sunday, 5th April)

1. Sorting:
This exercise is to ensure that you have understood file input/output, dynamic memory
allocation, and sorting.
You should write a program that should ask the user for the maximum number of input
numbers, N. Now, you should allocate memory for an array of integers of size N.
Then you should open a file named input.txt and read one number at a time and store it in
the array. Stop reading when either you hit end-of-file, or when you have read N numbers.
(That is, the file may have less or more numbers than N.)
Then your program should sort the numbers in the array using merge sort.
Write the numbers in the sorted form to another file named, output.txt.
If the file already exists, your program should overwrite it.
Maximum marks: 10
There is only one problem this week. This is the last problem in C language.

You might also like