Lab 04.docx
Lab 04.docx
Topics Today
1. While loop
2. For loop
Problem 1
You will take an integer number from the user. You have to find the summation of all the
digits.
Problem 2
In this problem, you will develop a program that can find how many times an integer
number can be divided by Two (2).
Problem 3
You will take several integer numbers as inputs until the user enters -1. Then calculate the
difference between the Highest and Lowest number.
Problem 4
Write a C program to calculate xy where x is base (an integer) and y is exponent (an
integer) as follows. The program should have a while repetition statement.
Problem 5
The factorial of a nonnegative integer n is written n! (pronounced “n factorial”) and is
defined as follows:
n! = n · (n – 1) · (n – 2) · ... · 1 (for values of n greater than 1)
and n! = 1 (for n = 0 or n = 1).
For example, 5! = 5 · 4 · 3 · 2 · 1, which is 120.
Write a program that reads a nonnegative integer, and computes and prints its factorial.
Problem 6
Write a program in C to check whether a number is a palindrome or not.
Test Data :
Input a number: 121
Expected Output :
121 is a palindrome number.