Assignment 1
Assignment 1
Assignment 1
Range of an array is the difference between the maximum and minimum element in an array,
Input consists of n+1 integers where n corresponds to the number of elements in the array.
The first integer corresponds to n and the next n integers correspond to the elements in the array.
All text in bold corresponds to input and the rest corresponds to output.
TEST CASE 1
INPUT
5
12435
OUTPUT
The input consists of (m*n+2) integers. The first integer corresponds to m, the number of rows in the
matrix and the second integer corresponds to n, the number of columns in the matrix. The remaining
integers correspond to the elements in the matrix. The elements are read in rowwise order, first row
first, then second row and so on. Assume that the maximum value of m and n is 10
TEST CASE 1
INPUT
33
123
456
789
OUTPUT
Not Symmetric
TEST CASE 2
INPUT
33
311
131
115
OUTPUT
Symmetric
5. There are 2 Programming Labs . Each with a seating capacity of 90. There are 240 students with
registration numbers from 1 to 240. All 240 students cannot be accommodated in the labs at the
same time. It has been decided to conduct theory class for 60 students every week. It has been
planned to conduct theory classes for all students with register number being a multiple of 4.
Students with registration number from to 1 to 120 with registration number not a multiple of 4
need to be seated in programming lab1 and students with registration numbers from 121 to 240 with
registration numbers not a multiple of 4 need to be seated in programming lab II.
Given the registration number of student, write a C program to specify the lab or hall in which
student need to be seated.
Input Format:
Input consists of 1 integer which corresponds to the registration number of the student.
Output format:
Output consists of string "Lab 1" or "Lab 2" or "Theory session " or ?Incorrect Register Number?
TEST CASE 1
INPUT
16
OUTPUT
Theory session
TEST CASE 2
INPUT
239
OUTPUT
Lab 2
6. Ms.Kirthiga, the faculty handling programming lab for you is very strict. Your seniors have told you
that she will not allow you to enter the weeks lab if you have not completed atleast half the number
of problems given last week. Many of you didnt understand this statement and so they requested the
good programmers from your batch to write a c program to find whether a student will be allowed
into a week lab given the number of problems given last week and the number of problem solved by
the students in that week.
Input format:
Input consists of 2 integers. The First integer corresponds to the number of problems given and the
second integer corresponds to the number of problems solved.
Output format:
Output consists of the string "IN" or "OUT"
Refer sample input and output for further formatting specifications.
TEST CASE 1
INPUT
8
3
OUTPUT
OUT
7.
A task is given to 3 persons to complete it within a particular time. If the person exceeds the time
limit he will be disqualified . Only those who complete it within the given time limit is qualified.
Among the qualified persons. the person who complete the task first will be rewarded.Write a C
program to find the person who is rewarded.
Input Format:
First Input corresponds to the time limit for the task in hours . Second, third and fourth input
corresponds to the number of hours taken by the first, second and third persons respectively to
complete the task.
Output format:
TEST CASE 1
INPUT
10 5 4 7
OUTPUT
TEST CASE 2
INPUT
4967
OUTPUT
No person wins!!
8. A student is eligible to be a class representative if his or her attendance % and marks is greater
that 90% and he or she doesnt have any arrears. Given the attendance % ,mark % and number of
arrears, write a C program to determine whether a student is eligible to be a Class Representative or
not.
Input format:
Input consists of 2 float and an integer. The first float corresponds to the attendance % and the
second float corresponds to the percentage of marks. The third input is an integer which corresponds
to the number of arrears.
Output format :
Output consists of the string "Eligible " or "Not Eligible"
Refer sample input and output for further formatting specifications.
TEST CASE 1
INPUT
90.1
90.1
0
OUTPUT
Eligible
TEST CASE 2
INPUT
90.0
90.0
0
OUTPUT
Not Eligible
9.
Tuzik is a little dog. But despite the fact he is still a puppy he already knows about the pretty things
that coins are. He knows that for every coin he can get very tasty bone from his master. He believes
that some day he will find a treasure and have loads of bones.
And finally he found something interesting. A wooden chest containing N coins! But as you should
remember, Tuzik is just a little dog, and so he cant open it by himself. Actually, the only thing he can
really do is barking. He can use his barking to attract nearby people and seek their help. He can set
the loudness of his barking very precisely, and therefore you can assume that he can choose to call
any number of people, from a minimum of 1, to a maximum of K.
When people come and open the chest they divide all the coins between them in such a way that
everyone will get the same amount of coins and this amount is maximal possible. If some coins are
not used they will leave it on the ground and Tuzik will take them after they go away. Since Tuzik is
clearly not a fool, he understands that his profit depends on the number of people he will call. While
Tuzik works on his barking, you have to find the maximum possible number of coins he can get.
Input
The first line of the input contains an integer T denoting the number of test cases. Each of next T
lines contains 2 space-separated integers: N and K, for this test case.
Output
For each test case output one integer - the maximum possible number of coins Tuzik can get.
Constraints
1<=T<=50
1<=N, K<=105
In the first example he should call two people. Each of them will take 2 coins and they will leave 1
coin for Tuzik.
TEST CASE 1
INPUT
2
52
11 3
OUTPUT
1
2
10. Write a program to display a grocery bill of the product purchased in the small market by John by
getting following input from the user
All text in bold corresponds to input and the rest corresponds to output.
TEST CASE 1
INPUT
soap
33.00
2
OUTPUT
Product Details
soap
33.000000
2
Bill:66.00