0% found this document useful (0 votes)
30 views11 pages

IPS 1 Question

Uploaded by

murherajat
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)
30 views11 pages

IPS 1 Question

Uploaded by

murherajat
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/ 11

IPS-1(I/O Statements-Formatting, Data Types)

1. Welcome Message
2. Event Details
3. Plot Fencing
4. Midpoint of a tape
5. Profit calculator
6. Team splitting
7. Average Sale
8. Concession availed
9. Lucky prize
10. Salary computation
11. Grading system

Welcome Message

The course instructor of Structured and Object-Oriented Programming planned to conduct an


In-lab Practicing Test on Basics of C and conditional statements. As a part of this test, she
ask students to write a code that will display customized welcome messages by taking
students’ name as input.

Input Format:
First line of the input is a string that corresponds to a student name. Assume that the
maximum length of the string is 50.

Output Format:
Output should display the welcome message along with the student’s name.
Refer sample input and output for formatting specifications.
[All text in bold corresponds to input and rest corresponds to output.]

Sample Input and Output:


Enter your name:
Beena
Hello Beena! Welcome to BCSE102L course.

Test cases:
Enter your name:
Jerish
Hello Jerish! Welcome to BCSE102L course.

Enter your name:


Arun
Hello Arun! Welcome to BCSE102L course.
Event

A food fest event was arranged by an organization and the organizer was asked to submit a
brief report about the event.
Write a program that will get the input of the event details like name of the event, type of the
event, number of people expected, a string value (Y/N) telling whether the event is going to
be a paid entry and the projected expenses (in lakhs) for the event. The program should then
display the input values as a formatted output.

Input Format:
First input is a string that corresponds to the name of the event. Assume the maximum length
of the string as 50.
Second input is a string that corresponds to the type of the event. Assume the maximum
length of the string as 50.
Third input is an integer that corresponds to the number of people expected for the event.
Fourth input is a character that corresponds to Y/N telling whether the event is going to be a
paid entry or not.
Fifth input is a double value that corresponds to the projected expenses (in lakhs) for the
event.

Output Format:
Output should display the event details as given in the sample output.
All double values need to be displayed correct to 1 decimal place
Refer sample input and output for formatting specifications.
[All text in bold corresponds to input and rest corresponds to output.]

Sample Input
Food Fest 2017
Public
5000
N
5.7

Sample Output:
Food Fest 2017
Public
5000
N
5.7

Plot Fencing
A man buys a rectangular plot. He decides to construct a wall around the plot and fill the
entire plot with sand. He wanted to buy only the exact quantity of sand that is needed to fill
the plot.

Help them by writing a C program to find the exact length of the wall and the exact area of
the plot?

Input Format:

Input consists of 2 integers. The first integer corresponds to the length of the plot and the
second integer corresponds to the breadth of the plot.

Output Format:

Refer Sample Input and Output for exact formatting specifications.

Sample Input

[All text in bold corresponds to input and the rest corresponds to output]

50

20

Output:

140

1000

MIDPOINT OF A TAPE
A measuring tape is placed between two places, and we need to find the mid position of the
tape.
Given the coordinates of the 2 end points of a line (x1,y1) and (x2,y2), write a C program to
find the midpoint of the line.
Input Format:
Input consists of 4 integers. The first integer corresponds to x1 . The second integer
corresponds to y1. The third and fourth integers correspond to x2 and y2 respectively.
Output Format:
Refer Sample Input and Output for exact formatting specifications.
[All floating point values are displayed correct to 1 decimal place]
Sample Input and Output:
[All text in bold corresponds to input and the rest corresponds to output]

Sample Input/Output 1:

2
4
10
15
6.0
9.5

Sample Input/Output 2:

10
20
30
50
20.0
35.5

Profit calculation
Each Sunday, a newspaper agency sells x copies of a certain newspaper for Rs.a per copy.
The cost spent by the agency for each newspaper is Rs. b . The agency pays a fixed cost of
Rs.100 per Sunday for storage, delivery and so on. The newspaper agency wants to calculate
the profit obtained on Sundays. Can you help them out by writing a C program to compute
the profit given x, a and b.

Input Format:

Input consists of 3 integers --- x, a and b. X is the number of copies sold, a is the cost per
copy and b is the cost the agency spends per copy.

Output Format:

Integer that represents Profit obtained

Sample Input and Output 1:

[All text in bold corresponds to input and the rest corresponds to output]

1000

900

Sample Input and Output 2:

1000

2900

Team splitting
During the English hour, professor has decided to conduct a skit. He wants to split the
students in the class into equal sized teams. In some cases, there may be some students who
are left out from teams and he wanted to use the left-out students to assist him in conducting
the skit.
For instance, if there are 50 students in the class and if the class has to be divided into 7 equal
sized teams, 7 students will be there in each team and 1 student will be left out.
Professor asks your help to automate this team splitting task. Can you please help him out?
Input Format:
Input consists of 2 integers. The first integer corresponds to the number of students in the
class and the second integer corresponds to the number of teams.
Output Format:
Display the number of students in each team and the number of students left out.
Sample Input and Output:
[All text in bold corresponds to input and the rest corresponds to output]
Input:
60
8
Output:
The number of students in each team is 7 and the number of students left out is 4

Test cases:

50
5
Output:
The number of students in each team is 10 and the number of students left out is 0

AVERAGE SALE

A grocer has a sale of Rs. s1, Rs. s2, Rs. s3, Rs. s4 and Rs. s5 for 5 consecutive months. How
much sale must he have in the sixth month so that he gets an average sale of Rs. x?
Write a C program to compute the sale for the 6th month.
Input Format:
Input consists of 5 integers and 1 float. The five integers correspond to s1, s2, s3, s4 and s5.
The float input corresponds to x.

Output Format:
Refer sample input and output for formatting specifications.
The float values are displayed correct to 2 decimal places.
Sample Input and Output:
[All text in bold corresponds to input and the rest corresponds to output]

Input :

6435
6927
6855
7230
6562
6500

Output

4991.00

Concession availed
A family decided to spend week-end in amusement park. The family comprises of 4 aged
person,2 adults and 2 children. A special concession is announced for children below 12
years as well for woman. Help the amusement park authorities to find whether if the person is
eligible for concession.
Input Format:
The first line of the input is integer that corresponds to the name of the person. The second
line of the input is an integer that corresponds to the age of the person and the third line is a
char that corresponds to gender.
Output Format:

The output should display "Concession" or "No Concession" based on the conditions given.
Refer sample input and output for formatting specifications.

Sample Input 1:

ajin
20
m

Sample Output 1:
no concession

Sample Input 2:
anju
20
f

Sample Output 2:
concession

Lucky Prize
A gambling company has announced some lucky prizes for the customers who purchased
lottery tickets. Based on this, the customers whose ticket number has the last digit as 5 or 7,
are declared as lucky winners and attracting prizes are waiting for them.
Write a program to find if the last digit of the ticket number of customers is 5 or 7.
Input Format:
First line of the input is an integer that corresponds to the ticket number.

Output Format:
Output should display as "Lucky Winner" if the last digit of the ticket number is 5 or 7.
Otherwise print "Not a Lucky Winner".
Refer sample input and output for formatting specifications.

Sample Input 1:
45

Sample Output 1:
Lucky Winner

Sample Input 2:
41

Sample Output 2:
Not a Lucky Winner

Pay slip

An employee has recently got his job in a software company. The Company has sent him a
detailed salary structure with details of his basic salary, HRA and DA. The Company has
promised to pay him as under:

If his basic salary is less than Rs. 15000, then HRA = 15% of basic salary and DA = 90% of
basic salary.
If his basic salary is either equal to or above Rs. 15000, then HRA = Rs. 5000 and DA = 98%
of basic salary.

If the employee’s salary is given as input, write a program to find his gross salary.

Note: Gross Salary = Basic Salary+HRA+DA

Input Format:
First line of the input is an integer that corresponds to the basic salary of employee.

Output Format:
Output should display the double value that refers to the gross salary of employee. Display
the output correct to 2 decimal places.
Refer sample input and output for formatting specifications.

Sample Input 1:
12000

Sample Output 1:
24600.00

Sample Input 2:
30000

Sample Output 2:
64400.00

GRADE
A university releases the semester results and posts it in the parent’s portal. Grades are
displayed for each course. Most of the parents are unaware of grading system. Help them
with a programming code (using switch) to understand the marks relevant to each grade.
Grade O – above 90%
Grade A-above 80%
Grade B-above 70%
Grade C-above 60%
Grade D-above 50%
Grade U-fail

Input Format:
First line of the input is a character that corresponds to the grade.

Output Format:
Output should display the string that refers to percentage of marks
Sample Input:
O
Sample Output:
above 90%

You might also like