Sie sind auf Seite 1von 1

ADVANCED COMPUTER PROGRAMMING

LABORATORY EXERCISE NO. 4


LOOPING STATEMENTS

1. Write a program to print all natural numbers from 1 to n using looping where n
is any number.
2. Write a program to print all natural numbers in reverse from n to 1 looping
where n is any number.
3. Write a program to enter any number from user and find the reverse of
number. Example:
Input: 1234
Output: 4321
4. Write a program to enter any number and convert it into words.
Example:
Input: 1234
Output: One Two Three Four

5. Write a program to enter any number and print all factors of given
number. Example:
Input any number: 12
All factors of 12 are: 1, 2, 3, 4, 6, 12
6. Write a program that enters two numbers and find the HCF(Highest Common
Factor) of the two numbers.
Example:HCF of 12 and 30 is 6
7. Write a program to enter any number from user and check whether the number is
Armstrong number or not. Armstrong number is a special number whose sum of
cube of its digits is equal to the original number.
Input: 371
Output: Armstrong number
371 is an Armstrong number because 3 3 + 73 + 13 = 371

8. Write a C program to print Fibonacci series upto n terms. Fibonacci series is a


series of numbers where the current number is the sum of previous two terms.
Example: 0, 1, 1, 2, 3, 5, 8, 13, 21...

Das könnte Ihnen auch gefallen