0% found this document useful (0 votes)
2 views

Lab 04.docx

The document outlines a structured programming lab session led by Md. Asif Khan Rifat, focusing on while and for loops. It presents six programming problems for students to solve, including summation of digits, division by two, finding the difference between highest and lowest numbers, calculating powers, computing factorials, and checking for palindromes. Sample inputs and outputs are provided for each problem to guide students in their coding tasks.

Uploaded by

flightfast24
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Lab 04.docx

The document outlines a structured programming lab session led by Md. Asif Khan Rifat, focusing on while and for loops. It presents six programming problems for students to solve, including summation of digits, division by two, finding the difference between highest and lowest numbers, calculating powers, computing factorials, and checking for palindromes. Sample inputs and outputs are provided for each problem to guide students in their coding tasks.

Uploaded by

flightfast24
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Course Instructor: Md.

Asif Khan Rifat​ Lab: 04


Course: CSE103 (Structured Programming)​

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.

Sample Input Sample Output


1234 10
678 21

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).

Sample Input Sample Output


32 5
61 0

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.

Sample Input Sample Output


7 5 1 9 5 -1 8
0 7 8 4 9 -1 9
2

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.

Sample Input Sample Output


Enter base: 2 8
Enter exponent: 3

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.

You might also like