01 Introduction and Fundamentals Practical

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

01 Introduction and Fundamentals

Practical Exercises

1. Write a program that uses printf to display the following picture on the screen

*
*
*
* *
* *
*

2. Write a program that computes the volume of a sphere that has a 10‐metre radius.

3. Modify the program for question 2 so that it prompts the user to enter the radius of
the sphere.

4. Write a program that prompts the user to enter a value for x and then displays the
value of

3x5 + 2x4 – 5x3 – x2 + 7x – 6.

5. Modify the program of question 4 for so that it evaluates

((((3x + 2)x – 5)x – 1)x + 7)x – 6.

P.T.O.! (Please Turn Over ‐ More questions on the other side).

6. Write a program that asks the user to enter an amount (in Rupiah) and then shows
how to pay that amount using the smallest number of 20,000, 10,000, 5,000 and
1,000 notes:

These questions are taken from the recommended textbook for this course:
K. N. King. C Programming; a Modern Approach (Second Edition). Norton and Company, 2008.
Enter a Rupiah amount: 93,000

20,000 notes: 4
10,000 notes: 1
5,000 notes: 0
1,000 notes: 3

7. Write a program that calculates the remaining balance on a loan after the first,
second and third monthly payments (in USD and cents):

Enter amount of loan: 20000.00


Enter interest rate: 6.0
Enter monthly payment: 386.66

Balance remaining after first payment: $19713.34


Balance remaining after second payment: $19425.25
Balance remaining after third payment: $19135.71

8. More exercises in the textbook.

These questions are taken from the recommended textbook for this course:
K. N. King. C Programming; a Modern Approach (Second Edition). Norton and Company, 2008.

You might also like