Chapter: Decision Control Structure | Let us C solution with details description and tutorials | Yashwant Kanetkar

Chapter: Decision Control Structure  | Let us C solution with details description and tutorials | Yashwant Kanetkar | 

S.NChapterS.NChapter
1Decision Control Structure5Arrays
2The Loop Control Structure6Puppetting On Strings 
3The Case Control Structure7Structures
4Function and Pointer8Input/Output in C


if,if-else,Nested if-else

[C] Attempt the following:

(a) If cost price and selling price of an item is input through the keyboard, write a program to determine whether the seller has made profit or incurred loss. Also determine how much profit he made or loss he incurred.

Show Solutions     Hide Solutions

(b) Any integer is input through the keyboard. Write a program to find out whether it is an odd number or even number. 

Show Solutions     Hide Solutions

(c) Any year is input through the keyboard. Write a program to determine whether the year is a leap year or not.
(Hint: Use the % (modulus) operator) 

Show Solutions     Hide Solutions

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

Show Solutions     Hide Solutions

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

Show Solutions     Hide Solutions

(f) If the ages of Ram, Shyam and Ajay are input through the keyboard, write a program to determine the youngest of the three.

Show Solutions     Hide Solutions

(g) 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 three angles is equal to 180 degrees.

Show Solutions     Hide Solutions

(h) Find the absolute value of a number entered through the keyboard.

Show Solutions     Hide Solutions

(i) 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.

Show Solutions     Hide Solutions

(j) 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. 

Show Solutions     Hide Solutions

(k) 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) 

Show Solutions     Hide Solutions

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

Show Solutions     Hide Solutions

[F] ([G] in 4th edition ) Attempt the following:

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

Show Solutions     Hide Solutions

  (b) Any character is entered through the keyboard, write a program to determine whether the character entered is a capital letter, a small case letter, a digit or a special symbol.
The following table shows the range of ASCII values for various characters.

Show Solutions     Hide Solutions

 (c) An Insurance company follows following rules to calculate premium.
(1) If a person’s health is excellent and the person is between 25 and 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 conditions 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 whether the person should be insured or not, his/her premium rate and maximum amount for which he/she can be insured.

Show Solutions     Hide Solutions

(d) A certain grade of steel is graded according to the following conditions: 
(i) Hardness must be greater than 50 
(ii) Carbon content must be less than 0.7 
(iii) Tensile strength must be greater than 5600 
The grades are as follows: 
Grade is 10 if all three conditions are met 
Grade is 9 if conditions (i) and (ii) are met 
Grade is 8 if conditions (ii) and (iii) are met 
Grade is 7 if conditions (i) and (iii) are met 
Grade is 6 if only one condition is met 
Grade is 5 if none of the conditions are met 
Write a program, which will require the user to give values of hardness, carbon content and tensile strength of the steel under consideration and output the grade of the steel.

Show Solutions     Hide Solutions

 (e) A library charges a fine for every book returned late. For first 5 days the fine is 50 paise, for 6-10 days fine is one rupee and above 10 days fine is 5 rupees. If you return the book after 30 days your membership will be cancelled. Write a program to accept the number of days the member is late to return the book and display the fine or the appropriate message.

Show Solutions     Hide Solutions

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

Show Solutions     Hide Solutions

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

 

Show Solutions     Hide Solutions

 (h) In a company, worker 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 keyboard, find the efficiency of the worker.

Show Solutions     Hide Solutions

(i) A university has the following rules for a student to qualify for a degree with A as the main subject and B as the subsidiary subject: 
(a) He should get 55 percent or more in A and 45 percent or more in B. 
(b) If he gets less than 55 percent in A he should get 55 percent or more in B. However, he should get at least 45 percent in A. 
(c) If he gets less than 45 percent in B and 65 percent or more in A he is allowed to reappear in an examination in B to qualify. 
(d) 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.

Show Solutions     Hide Solutions

(j) The policy followed by a company to process customer orders is given by the following rules:
(a) If a customer order is less than or equal to that in stock and has credit is OK, supply has requirement.
(b) If has credit is not OK do not supply. Send him intimation.
(c) If has credit is Ok but the item in stock is less than has order, supply what is in stock. Intimate to him data the balance will be shipped.
Write a C program to implement the company policy 

Show Solutions     Hide Solutions

[J]( [k]in 4th edition) Attempt the following:

 (a)Using conditional operators determine:
(1) Whether the character entered through the keyboard is a lower case alphabet or not.
(2) Whether a character entered through the keyboard is a special symbol or not.

Show Solutions     Hide Solutions

(b) Write a program using conditional operators to determine whether a year entered through the keyboard is a leap year or not.

Show Solutions     Hide Solutions

 (c) Write a program to find the greatest of the three numbers entered through the keyboard using conditional operators. 

Show Solutions     Hide Solutions

Comments

Popular posts from this blog

Puppetting on string | Let us C solution with details description and tutorials | yashwant kanetkar

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