You are on page 1of 4

15CSE180 Computer Programming Lab

Periodical Lab ­ 1
(30 Marks)
Set – 1

1. An online retailer sells five different products whose retail prices are shown
in the following table.

S. No. Product Retail Price


No. (Rs.)
1 1122 149
2 2211 225
3 2121 499.5
4 1212 224.5
5 2112 343.5

Write a C program that reads quantity sold one day of each product to print
summary of a week’s selling status. A sample session follows.

Quantity of 1122 sold in this week: 2


Quantity of 2211 sold in this week: 3
Quantity of 2121 sold in this week: 1
Quantity of 1212 sold in this week: 2
Quantity of 2112 sold in this week: 3

Weekly statement
product no quantity Unit price amount
1122 2 149.00 298.00
2211 3 225.00 675.00
2121 1 499.50 499.50
1212 2 224.50 449.00
2112 3 343.50 1030.50
2. Given two unsorted arrays (with duplication of elements allowed), write a
program to check whether both arrays have same elements are not.

Given {2, 5, 6, 8, 10, 2, 2} and {2, 5, 5, 6, 8, 10, 6} the


answer should be No.

Given {2, 5, 8, 6, 10, 2, 2} and {10, 2, 8, 5, 6, 2, 2} the


answer should be yes
15CSE180 Computer Programming Laboratory
Periodical Lab – 1
(30 Marks)
Set – 2

1. An electronics shop sells items such as TV, Washing machine, Refrigerator,


Computer, Laptop and iPod. All the products have some discounts. (Assume
price for each product!!) Write a Menu driven program (use functions) to
calculate the cost of the products a customer buys. (Discount for TV &
Washing machine ­ 10%, Refrigrator & Computer – 15%, Laptop & iPod –
20%).

Sample Session Follows:

MENU
---------------------
1. TV
2. Washing machine
3. Refrigerator
4. Computer
5. Laptop
6. ipod
---------------------

ENTER YOUR CHOICE: 1

ACTUAL AMOUNT : Rs. 36000


DISCOUNT (%) : Rs. 3600
NET AMOUNT : Rs. 32400

DO YOU WANT TO CONTINUE PURCHASING: (Y/N)? Y

ENTER YOUR CHOICE: 2

ACTUAL AMOUNT : Rs. 25000


DISCOUNT (%) : Rs. 2500
NET AMOUNT : Rs. 22500
DO YOU WANT TO CONTINUE PURCHASING: (Y/N)? N

THANK YOU

You bought 2 items. Total cost = Rs. 54900

2. Given a sorted array, write a program that makes array elements distinct by
increasing element values but at the same time keeping array sum minimum
possible. Print the modified array and minimum sum.

Given {20, 20} the output should be {21, 20} or {20, 21} and sum =
41.

Given {2, 2, 3, 5, 6} the output should be {2, 3, 4, 5, 6} and sum


= 20

Given {3, 4, 6, 8} the output should be No change (as all the array
elements are already distinct).

You might also like