0% found this document useful (0 votes)
5 views4 pages

Discount Calculation and Lucky Number Check

Uploaded by

22cs054
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

Discount Calculation and Lucky Number Check

Uploaded by

22cs054
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

1. If the total cost is between 50 and 99.99, a 5% discount is applied.

2. No discount is applied if the total cost is less than 50.

The program should output the total bill after applying the discount with two decimal places.
Input format :
The input consists of three double values, representing the number of units consumed for
electricity, water, and gas respectively.
Output format :
The output prints a double value, representing the total bill after applying the discount,
formatted to two decimal places.

Refer to the sample output for formatting specifications.


Code constraints :
Single File Programming Question
Problem Statement

Joe has a favourite number, let's call it X. He wants to check if X is divisible by the sum of its
digits. If it is, he considers it a lucky number. If not, he wants to find the closest smaller lucky
number. Joe has challenged his friends to solve this puzzle at his birthday party.

Your task as one of Joe's friends is to help him with this challenge using the 'while' loop. You
need to write a program that takes Joe's favourite number X as input, and then:
1. Check if X is a lucky number (divisible by the sum of its digits).
2. If it is a lucky number, congratulate Joe and let him know.
3. If it is not a lucky number, find and display the closest smaller lucky number.
Input format :
The input consists of an integer X, representing Joe's favourite number.
Output format :
If X is a lucky number, then the output must be in the format: "X is divisible by the sum of its
digits."
If not, then the output must be in the format:
"X is not divisible by the sum of its digits.
The closest smaller number that is divisible: Y",
where X is the entered number and Y is the closest number.

Refer to the sample output for formatting specifications.


Code constraints :
Single File Programming Question
Problem Statement

Write a program that finds the second-largest element in the array.


Input format :
The first line of the input consists of the value of n.
The second line of input consists of an array of elements.
Output format :
The output prints the second-largest element in the array.

Refer to the sample output for format specifications.


Code constraints :
1 <= n <= 20
1 <= arr[i] <= 1000

Single File Programming Question


Problem Statement

Write a program to obtain a matrix and find the sum of each row and each column.
Input format :
The first line of the input consists of the number of rows M and columns N separated by
space.
The next M lines of input consist of N elements in each line separated by space.
Output format :
The output prints the sum of each row and each column, separated by a line.

Refer to the sample outputs for the formatting specifications.


Code constraints :
1 <= M, N <= 10
-1000 <= elements <= 1000

You might also like