You are on page 1of 1

Lab 5

(20-3-2013)
1. Write a program that displays the table of number given by user. Using while loop and then
for loop.
2. Write an application that calculates the product of the odd integers from 1 to 15.
3. Write a C program that uses a while statement and the tab escape sequence \t to print the
following table of values: after doing it with while used for loop to achieve this task.
N 10*N 100*N 1000*N

1 10 100 1000
2 20 200 2000
3 30 300 3000
4 40 400 4000
5 50 500 5000


4. A positive integer is called a perfect number if it is equal to the sum of all of its positive
divisors, excluding itself. For example, 6 is the first perfect number because 6 = 3 + 2 + 1.
The next is 28 = 14 + 7 + 4 + 2 + 1. There are four perfect numbers less than 10000. Write a
program to find all these four numbers.

5. Suppose you put $10,000 into a CD with an annual percentage yield of 5.75%. After one
month, the CD is worth
10000 + 10000 * 5.75 / 1200 = 10047.91
After two months, the CD is worth
10047.91 + 10047.91 * 5.75 / 1200 = 10096.06
After three months, the CD is worth
10096.06 + 10096.06 * 5.75 / 1200 = 10144.43
and so on Write a program that prompts the user to enter an amount (e.g., 10000), the
annual percentage yield (e.g., 5.75), and the number of months (e.g., 18) and displays a
table for a year.

6. The process of finding the largest number (i.e., the maximum of a group of numbers) is used
frequently in computer applications. For example, a program that determines the winner of
a sales contest inputs the number of units sold by each salesperson. The salesperson who
sells the most units wins the contest. Write a pseudocode program, then a C program that
uses a while statement to determine and print the largest number of 10 numbers input by
the user. Your program should use three variables, as follows:
counter: A counter to count to 10 (i.e., to keep track of how many numbers have been
input and to determine when all 10 numbers have been processed).
number: The current number input to the program.
largest: The largest number found so far.

You might also like