Code Like Pro!

If/Else and Conditional Operator

  1. Write a program to check if an entered number is even or odd, without using the % operator.
  2. Write a program to find the maximum of three numbers, using conditional operator.
  3. Write a program to check if an entered year is Leap Year or not. (Hint: A Leap Year is a year containing 366 days)
  4. A company hires 4 different types of employess: HR Personnel, Manager, Project Lead or Techie. Given the following information about the salary given to the employees of the company, write a program which accepts the basic salary of the employee and calculates the gross salary and also displays the employee type. (Lower limit of basic salary is inclusive)

    Employee Type Basic Salary HRA DA TA
    HR Personnel 40lpa - 50lpa 15% 5% 7.5%
    Manager 30lpa - 40lpa 12% 3% 5%
    Project Lead 20lpa - 30lpa 10% 25K 50K
    Techie 8lpa - 20lpa 7.5% - 40K
  5. The grading system of NIT Durgapur is shown below. Given the marks of a student for any subject, write a program to calculate his/her grade for the subject. (Hint: Use minimum number of if-else)

    Marks Grade
    >= 90 Ex
    80-89 A
    70-79 B
    60-69 C
    50-59 D
    40-49 P
    < 40 F
  6. Given the coordinates of a point on the 2D plane, write a program to determine quadrant of the point.
  7. Given the coordinates of 4 points on the 2D plane, write a program which accepts the coordinates of another point and determines whether the point lies within the quadrilateral formed by the first four points.
  8. Given the coordinates of 3 points on the 2D plane, write a program to determine the type of triangle formed by those points – Scalene, Isosceles or Equilateral.
  9. Given the coordinates of 3 points on the 2D plane, write a program to determine the type of triangle formed by those points – Acute-angled, Right-angled or Obtuse-angled.
  10. Write a program which finds out the roots of a quadratic equation of the form ax2 + bx + c = 0, where a,b and c will be entered by the user.

Solution will be uploaded soon.

You are supposed to write the code for all problems and then check the solution file. The code present in the solution is supposed to be the best and most efficient code. You can mail your solution to me on ankan.learncwithme@gmail.com and I'll surely check it and if I find it better I'll put it in the solution.