Day 1
Day 1
Coding
C Language
Q1- Compute Area of Rectangle
Given the length of 3 sides of a triangle, check whether the triangle is valid or
not.
Input Format
First and only line of input contains three integers A, B, C - length of sides of
the triangle.
Output Format
Print "Yes" if you can construct a triangle with the given three sides, "No"
otherwise.
Sample Input-1 Sample Output-1
435 Yes
Sample Input-2 Sample Input-2
9 15 2 No
Q3- Number Reverse
One hot summer day Pete and his friend Billy decided to buy a watermelon. They
chose the biggest and the ripest one, in their opinion. After that the watermelon
was weighed, and the scales showed w kilos. They rushed home, dying of thirst,
and decided to divide the berry, however they faced a hard problem.
Pete and Billy are great fans of even numbers, that's why they want to divide the
watermelon in such a way that each of the two parts weighs even number of
kilos, at the same time it is not obligatory that the parts are equal. The boys are
extremely tired and want to start their meal as soon as possible, that's why you
should help them and fi nd out, if they can divide the watermelon in the way they
want. For sure, each of them should get a part of positive weight.
Q5- Watermelon
Input Format
The first (and the only) input line contains integer number w
(1 ≤ w ≤ 100) — the weight of the watermelon bought by the
boys.
Output Format
Print YES, if the boys can divide the watermelon into two parts,
each of them weighing even number of kilos; and NO in the
opposite case.
Sample Input Sample Output
8 Yes
Note
For example, the boys can divide the watermelon into two parts of 2 and 6
kilos respectively (another variant — two parts of 4 and 4 kilos).
Q6- ATM
Pooja would like to withdraw x US from an ATM. The cash machine will only accept the
transaction x which is a multiple of 5, and Pooja’s account balance has enough cash
US.
Calculate Pooja’s account balance after an attempted transaction.
Input Format
Each input contains 2 integers X and Y.
X is the amount of cash which Pooja wishes to withdraw.
Y is Pooja's initial account balance.
Output Format
Output the account balance after the attempted transaction, given as a number with
two digits of precision. If there is not enough money in the account to complete the
transaction, output the current bank balance.
Q6- ATM
Alice buys a toy with a selling price of 100 rupees. There is a discount
of x percent on the toy. Find the amount Alice needs to pay for it.
Input Format
The first line of input will contain a single integer T, denoting the
number of test cases.
The first and only line of each test case contains a single integer, x —
the discount on the toy.
Output Format
For each test case, output on a new line the price that Alice needs to
pay.
Sample Input Sample Output
4
5 95
9 91
11 89
21 79
Note
The discount is 5 percent, i.e., 5 rupees. So, Alice will have to pay 100 – 5 = 95 rupees.
Q8- Sum or Difference
Find the sum of the first and the last digit in four-digit positive
integer.
Input Format
One four-digit positive integer.
Output Format
Print the sum of the first and the last digit.
Sample Input Sample Output
1235 6
Q14- Sum of Digits