Assgn-III Au23
Assgn-III Au23
Assgn-III Au23
Write your name, roll number and assignment number in the header of the
program file as comments. You may give your program file name as
<asgn><no_><RollNo>.c. For example, a student with roll number 23CS1001
should name the program file for assignment number 32(a), as
asgn3a_23CS1001.c. Submit all the programs in the Moodle System 15 minutes
before the end of the laboratory session. Provide also output files containing
results given the set of inputs given here. Please follow the instruction for
generating result files provided at the end.
(a) Write a program to read marks in the Programming and Data Structure
Laboratory (out of 100) for N (to be read before) students. Compute the mean,
median and modes (i.e. maximally occurring values) of the score. Print the
following:
(i) The number of students
(ii) The scores in the order they are read. In each line there should be at
most five values printed. Each value except the last one in the line
should be followed by a comma, and then a blank space.
(iii) mean, median and modes.
Mean: 54.4
Median: 52
Modes: 56, 89
Provide results for the following input datasets:
(i) N=20
78, 45, 98, 23,18, 90, 94, 53, 67, 98, 23,18, 90, 78, 45, 98, 94, 53, 67, 98
(ii) N=13
32, 81, 9, 49, 100, 76, 89, 32, 81, 9, 87, 54, 89
(b) Write a program which reads N (to be read) coordinate points in two 1-D
arrays, each for x and y-coordinates of the points, and compute the leftmost
point (with minimum x-coordinate), the rightmost point (with maximum x-
coordinate), the bottommost point (with minimum y-coordinate), and the
topmost point (with maximum y-coordinate). Compute the minimum area of
the axis parallel rectangle enclosing the points.
Print N, the input set of 2-D points (at most 5 points in each line requiring
minimum number of lines to print), all the computed points and the area of
the rectangle as mentioned before.
N=8
(1,2), (-3.4, 2.8), (-4, 5), (8, -9), (3.56, 8.29), (10, 5), (3, -4), (0, 0)
N=8
(4, 8.54), (-6,10.2), (8, -3.5), (45, -19), (9, 20), (0,0), (1, 5), (-2, 10), (11, 21), (1,1)
(ii) N=3
All the results for each assignment should be submitted together in a separate
file (named result.txt). Provide the result in a separate output file (named,
result_<assgn><no>.txt). Use standard output redirection feature to generate
the output file.
Hints. Suppose you would like to redirect your output to a file ‘result.txt’.
If you run the program with the following command
./a.out >result.txt
If you execute the program multiple times, you may concatenate the
outputs in a single file by using the following redirection command:
./a.out >>result.txt
You may also store your input (the ordering as per requirement of
the program should be preserved) in an input file in.txt, and execute the
program as follows: