FYBCS C Exercise_2

Set A: Apply all the three program development steps for the following examples. 

 1. Write a program to accept an integer and check if it is even or odd. 

 2. Write a program to accept three numbers and check whether the first is between the other two numbers. Ex: Input 20 10 30. Output: 20 is between 10 and 30 

 3. Accept a character as input and check whether the character is a digit. (Check if it is in the range ‘0’ to ‘9’ both inclusive) 

 4. Write a program to accept a number and check if it is divisible by 5 and 7. 

 5. Write a program, which accepts annual basic salary of an employee and calculates and displays the Income tax as per the following rules. 
Basic: < 1,50,000                     Tax = 0
               1,50,000 to 3,00,000 Tax = 20%
            > 3,00,000                    Tax = 30% 

 6. Accept a lowercase character from the user and check whether the character is a vowel or consonant. (Hint: a,e,i,o,u are vowels)

B: Apply all the three program development steps for the following examples. 

 1. Write a program to check whether given character is a digit or a character in lowercase or uppercase alphabet. (Hint ASCII value of digit is between 48 to 58 and Lowercase character shave ASCII values in the range of 97 to 122, uppercase is between 65 and 90) 

 2. Accept the time as hour, minute and seconds and check whether the time is valid. (Hint:0<=hour<24, 0<=minute <60, 0<=second <60)

 3. Accept any year as input through the keyboard. Write a program to check whether the year is a leap year or not. (Hint leap year is divisible by 4 and not by 100 or divisible by 400)

 4. Accept three sides of triangle as input, and print whether the triangle is valid or not. (Hint:The triangle is valid if the sum of each of the two sides is greater than the third side).

 5. Accept the x and y coordinate of a point and find the quadrant in which the point lies. 

 6. Write a program to calculate the roots of a quadratic equation. Consider all possible cases.

 7. Accept the cost price and selling price from the keyboard. Find out if the seller has made a profit or loss and display how much profit or loss has been made. 

Set C: Write programs to solve the following problems.

 1. Write a program to accept marks for three subjects and find the total marks secured ,average and also display the class obtained. (Class I – above __%, class II – ___% to ___%,pass class – ___% to ___% and fail otherwise) 

 2. Write a program to accept quantity and rate for three items, compute the total sales amount,Also compute and print the discount as follows: (amount > ____– 20% discount, amount between___ to _____ -- 15% discount, amount between – ____ to ____ -- 8 % discount) 

 3. A library charges a fine for every book returned late. Accept the number of days the member is late, compute and print the fine as follows:(less than five days Rs ___ fine, for 6 to 10 days Rs.____ fine and above 10 days Rs. ___ fine ) 

Post a Comment

0 Comments