Initial Basics – Algebra – Problem #28

IIT Kharagpur CS10001 / CS11001 Programming and Data Structures Lab Question Archive

Difficulty: Hard

Problem Statement

Write a C Program that reads in five integers. If the numbers are not distinct, it prints “NOT DISTINCT” and terminates. If they are all distinct, then it finds and prints the following: largest, smallest, sum and median of the five numbers. Save the file as A03_<Roll Number>.c (example A03_21AG10002.c). Build, Run for and test it for the given data. Then upload the .c file for the Assignment. In particular, you will do the following: 1. Read five integers and print them. They must be printed in a single line with commas in between numbers. 2. If the numbers are not distinct, in a new line, print “NOT DISTINCT” and terminate If they are all distinct, then print the following in a new line each a) Largest of the five numbers as – Largest = <Print the largest number> b) Smallest of the five numbers as – Smallest = <Print the smallest number> c) Sum of the five numbers as – Sum = <Print the sum> d) Median of the five numbers as – Median = <Median of the five numbers> Test Data: (Inputs will be given one after another without commas) a) 7 9 23 1 5 b) 3 7 19 -1 8 c) 4 1 9 11 9 d) -2 8 0 -1 -9

Back to Lab Problems
Initial Basics/Algebra/Problem #28

Lab Problem Statement

Specifications & Problem DetailsIIT Kharagpur PDS Archive
Loading question...

Interactive C Compiler · Problem #28

WASM In-Browser

Runs directly on your machine · Zero remote server dependency

Compiler downloads on first Run (large, saved in your browser after that)
main.cCtrl + Enter to run
1
2
3
4
5
6
7
Input (stdin)given to scanf / cin
Output

Output appears here. Press Run to compile and execute.