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

Lab 8

Lab 8 consists of three tasks involving unsigned integers. Task 1 requires a program to read five integers and display their sum, Task 2 compares two integers to find and display the largest, and Task 3 does the same to find and display the smallest integer. Each task includes pseudocode for implementation.

Uploaded by

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

Lab 8

Lab 8 consists of three tasks involving unsigned integers. Task 1 requires a program to read five integers and display their sum, Task 2 compares two integers to find and display the largest, and Task 3 does the same to find and display the smallest integer. Each task includes pseudocode for implementation.

Uploaded by

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

Lab 8:

Task 1 Write a program that reads five unsigned integers from the user and displays
the sum of those five integers on the screen.
# Initialize a variable to store the sum
Sum = 0
# Read five unsigned integers from the user
For I in range(5):
Num = int(input(“Enter an unsigned integer: “))
If num>= 0:
Sum += num
# Display the sum
Print(“The sum of the five integers is:”, sinpu

Task 2 Write a program that takes two unsigned integers from the user, compares
Them and displays the largest one on the screen.
# Read the first unsigned integer from the user
Num1 = int(input(“Enter the first unsigned integer: “))
# Read the second unsigned integer from the user
Num2 = int(input(“Enter the second unsigned integer: “))
# Compare the two numbers and find the largest one
If num1 > num2:
Largest = num1
Else:
Largest = num2

# Display the largest number


Print(“The largest number is:”, largest)

Task 3:
Write a program that takes two unsigned integers from the user, compares
them and displays the smallest one on the screen.
# Read the first unsigned integer from the user
Num1 = int(input(“Enter the first unsigned integer: “))
# Read the second unsigned integer from the user
Num2 = int(input(“Enter the second unsigned integer: “))
# Compare the two numbers and find the smallest one
If num1 < num2:
Smallest = num1
Else:
Smallest = num2
# Display the smallest number
Print(“The smallest number is:”, smallest)

You might also like