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

S.S. Coachings, S.C.O. 30, Sector: 41-D, Chandigarh: Assignment: Selection Structure

The document provides 25 problems involving selection structures and conditional logic. The problems cover a range of topics including determining profit/loss, checking for leap years, calculating day of the week, reversing and comparing numbers, finding minimum/maximum values, checking triangle validity, grading systems, calculators, insurance eligibility, steel grading, and more. The problems are to be solved by writing programs that use logical and relational operators as well as selection structures like if/else statements and switch cases.
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)
43 views4 pages

S.S. Coachings, S.C.O. 30, Sector: 41-D, Chandigarh: Assignment: Selection Structure

The document provides 25 problems involving selection structures and conditional logic. The problems cover a range of topics including determining profit/loss, checking for leap years, calculating day of the week, reversing and comparing numbers, finding minimum/maximum values, checking triangle validity, grading systems, calculators, insurance eligibility, steel grading, and more. The problems are to be solved by writing programs that use logical and relational operators as well as selection structures like if/else statements and switch cases.
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/ 4

Assignment : Selection Structure

1. If cost price and selling price of an item is input through the keyboard .Write a
program to find out whether the seller has made profit or incurred loss .Also determine
how much profit he made or loss he incurred.

2. Any integer is input through the keyboard .Write a program to find out whether the year is a
leap year or not. e(HINT: Use the % (modulus) operator)[ Every year that is exactly divisible by
four is a leap year, except for years that are exactly divisible by 100, but these years are leap years if they are
exactly divisible by 400.
3. For example, the years 1700, 1800, and 1900 are not leap years]

4. According to the Gregorian calendar , it was Monday on the date 01/01/01.If any year is
input through the keyboard write a program to find out what is the day on 1st January of this
year.

5. A five-digit number is entered through the keyboard .Write a program to obtain the number
and to determine whether the original and reversed numbers are equal or not.

6. If the ages of Ram, Shyam and Ajay are input through the keyword, write a program to
determine the youngest of these.

7. Write a program to check whether a triangle is valid or not ,when the three angles of the
triangle are entered through the keyboard .A triangle is valid if the sum of all the these
angles is equal to 180 degrees.

8. Find the absolute value of a number entered through the keyboard.

9. Given the length and breadth of a rectangle, write a program to find whether the area of the
rectangle is greater than its perimeter .For example, the area of the rectangle with length =
5 and breadth = 4 is greater than its perimeter.

10.Given three points (x1, y1), (x2, y2) and (x3, y3) .Write a program to check if all the three
points fall on one straight line.

11.Given the coordinates (x, y) of a center of a circle and it’s radius .write a program which will
determine whether a point lies inside the circle, on the circle or outside the circle.

(Hint: Use sqrt() and pow() functions))

12.Given a point (x, y), write a program to find out if it lies on the x-axis, y-axis or on the
origin, viz.(0,0).
13.a

14.A general foram of quadratic equation is ax2 + bx + c = 0 , to find its roots we will first
compute its discriminant i.e. d = b2 – 4ac .

if d<0 there will be no real roots


if d==0 there will equal and real roots
if d>0 there will be unequal and real roots

to compute roots the formula is :

x1 = (-b + sqrt(d))/2a x2 = (-b-sqrt(d))/2a

Write a program to compute and print the roots of quadratic equation, use if statement to
check the

S.S. Coachings, S.C.O. 30, Sector : 41-D,Chandigarh


Assignment : Selection Structure
condition satisfied by the value of Discriminant.

15.A library has certain criteria to charge fine for late return of books :

If the book is returned 5 to 10 days late : fine will be 3% of the book price * no of days
If the book is returned 11 to 15 days late : fine will be 4% of the book price * no of days
If the book is returned 16 to 20 days late : fine will be 5% of the book price * no of days

Write a program to compute and print the fine payable by a customer. The operator will
enter the no of
days the book is returned late. Use if statement to check the condition applied.

16.There are certain criteria followed for the grading system in a school :

If total <=100 and total>90 a student will get distinction


If total <=90 and total>80 a student will get honors
If total <=80 and total>70 a student will get first division
If total <=70 and total>60 a student will get second division
If total <=60 and total>50 a student will get third division
If total<=50 then a student will be declare fail

Write a program in which the total marks will be entered and grade of a student will be
computed and
printed. Use else if ladder and logical operator to combine more than one expression.

17.Write a program to develop a calculator which can do addition, subtraction, multiplication,


division and can find remainder value, The format will be :

Enter the First number :


Enter the second number :

1. +
2. –
3. *
4. /
5. %
Your Option :

If a valid option is entered the calculator will compute and print the result. use
switch
statement to check the condition.

18.Any year is entered through the keyboard, write a program to determine weather the year is
leap or not. Use the logical operators && and ||.

S.S. Coachings, S.C.O. 30, Sector : 41-D,Chandigarh


Assignment : Selection Structure

19.An insurance company follows following rules to calculate premium.

1. If a person health is excellent and the person is in between 25-35 years of age and
lives in a city and is a male. Then the premium is Rs. 4 per thousand and his policy
amount cannot exceed Rs. 2 lakhs.
2. if a person satisfies all the above condition except that the sex is female then the premium is
Rs. 3 per thousand and her policy amount cannot exceed Rs. 1 lakh.
3. If a person’s health is poor and the person is between 25 and 35 years of age and
lives in a village and is a male then the premium is Rs. 6 per thousand and his policy
cannot exceed Rs. 10,000.
4. In all other cases the person is not insured.

Write a program to output weather the person should be insured or not, his/her premium
rate and maximum amount for which he/she can be insured.

20. A certain grade of steel is graded according to the following conditions :

1. Hardness must be greater than 50


2. Carbon content must be less than 0.7
3. Tensile strength must be greater than 5600

The grade are as follows :

Grade is 10 if all three condition are met.


Grade is 9 if conditions 1 and 2 are met.
Grade is 8 if conditions 2 and 3 are met.
Grade is 7 if conditions 1 and 3 are met.
Grade is 6 if only one condition is met.
Grade is 5 if none of the conditions are met.
-zinzzii!
Write a program which will require the use to give values of hardness, carbon content
and tensile strength of the steel under consideration and output the grade of the steel.

21.If the three sides of a triangle are entered through the keyboard, write a program to check
weather the triangle is valid or not. The triangle is valid if the sum of the two sides is
greater than the largest of the three sides.

22.If the three sides of the triangle are entered through the keyboard, write a program to
check weather the triangle is isosceles, equilateral, scalene or right angled triangle.

23.In a company the work efficiency is determined on the basis of the time required for a
worker to complete a particular job. If the time taken by the worker is between 2-3 hours,
then the worker is said to be highly efficient. If the time required by the worker is between
3-4 hours, then the worker is ordered to improve speed. If the time taken is between 4-5
hours, the worker is given training to improve his speed and if the time taken by the worker
is more than 5 hours, then the worker has to leave the company, if the time taken by the
worker is input through the keyword, find the efficiency of the worker.

S.S. Coachings, S.C.O. 30, Sector : 41-D,Chandigarh


Assignment : Selection Structure

24.A university has the following rules for a student to qualify for a degree with A as the main
subject and B as tuhe subsidiary subject:

1. He should get 55% or more in A andl 45% or more in B


2. if he gets less than g
3. 55% in A he should get 55% or more in B. However he should get at least 45% in A.
4. if he gets less than 45% in B and 65% or more in A he allowed to reappear in an
examination in B to qualify.
5. In all other cases he is declared to have failed.

Write a program to receive marks in A and B and output whether the student has passed,
failed or is allowed to reappear in B.

25. The policy followed by a company to process customer orders is given by the following rules.

1. if a customer order quality is less than or equal to that in the stock and his credit is ok,supply
his requirement.
2. if his credit is not ok do not supply. Send him intimation .
3. if his credit is ok but the item in stock is less than his order, supply what is in stock. Intimate to
him the date on which the balance will be shipped.
Write a program to implement the company policy.

S.S. Coachings, S.C.O. 30, Sector : 41-D,Chandigarh

You might also like