Code Like Pro!

Basic Input Output

  1. Risabh’s basic salary is given as input through the keyboard. His dearness allowance is 25% of basic salary, house rent allowance is 15% of basic salary and provident fund is 7.5% of basic salary. Write a program to calculate his gross salary.
  2. Write a program which takes a Fahrenheit temperature as input and prints the equivalent Celsius temperature.
  3. Write a program to receive Cartesian coordinates (x,y) of a point and convert them to polar coordinates (r,φ). (Hint: r = sqrt (x2 + y2) and φ = tan-1(y/x))
  4. Write a program which takes two integers as input, which denote meters and centimeters, and converts this distance into feet and inches. (Hint: 1 Inch = 2.54 Centimeters and 12 Inches = 1 Foot)
  5. Write a program which takes the principal amount, rate of interest and number of years and calculates the amount after the entered number of years if the principal amount is compounded quarterly at the entered rate of interest for the entered time.
  6. Write a program to swap or interchange the contents of two integer variables, using a third variable.
  7. Write a program to swap or interchange the contents of two integer variables, without using a third variable.
  8. Write a program to calculate the sum of the series: 1+2+3+4+…+n, where n is entered by the user, without using iteration or recursion. (Hint: Use Summation of Arithmetic Progression)
  9. Write a program to calculate the sum of the series: 1+2+4+8+…+2n, where n is entered by the user, without using iteration or recursion. (Hint: Use Summation of Geometric Progression)
  10. If the lengths of 3 sides of a triangle are provided as input, write a program to find the three angles of the triangle. (Hint: Use Coisine Formula)

Find the solutions here.

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.