You Have To Implement All The Given Programming Objects Using User-Defined Functions
You Have To Implement All The Given Programming Objects Using User-Defined Functions
Tajwar Sultana
Assignment # 02
Instructions: You have to implement all the given programming objects using user-defined functions. 1. Write a program to calculate the volume of a box. 2. Write a program to evaluate the expression: a. A + b b. A B c. A/B d. Remainder of A/B Use integer, float or double, exponent formats and variables for printing with different types of modifiers. 3. Write a program to evaluate a function: f(x) = ax2 + b if b >= 2 f(x) = ax + bx if b < 2 4. Write a program which asks for the students age. On the basis of the given age, it decides whether the student can appear for the contest or not. If the age is between 5 and 15 then it displays the message student can appear for contest, otherwise student cannot appear for contest. 5. Write a program to calculate discount to be given to the customer on purchasing of items. Take the price and number of products purchased by the customer as input. If the price is more than 5000 and the number of products purchased is more than 5, then the discount is paid as 5%, otherwise the discount given on product is zero. 6. Write a program to find whether a quadratic equation has real or imaginary roots. ax2 + bx + c = 0 if the roots are real then display the results. 7. Write a program to find whether the year is a leap year. Take the year as input. 8. Write a program to find the value of Y for a particular value of K If K = 1 then Y = ax + b If K = 2 then Y = ax2 + b2 If K = 3 then Y = -ax If K = 4 then Y = a + x The values of a, x, b, k are supplied through keyboard. 9. Write the above program using switch statement. 10. Write a program to calculate the sum of even numbers upto 100. Page 1 of 2
EL-254 Programming with C-Language Course Teacher: Ms. Tajwar Sultana S = 2 + 4 + 6 + + 100
Assignment # 02
11. Write a program to generate Fibonacci series. Fibonacci series is the one in which every number is generated by sum of two previous terms. The first two terms are generating terms. Example: 1 1 2 3 5 8 13 21. N terms Take two initial values of the series as input from user and generate the remaining series till 10th term.
Page 2 of 2