835 views
5 votes
Write a program that reads three integers and then prints them in the order read and reversed. Use 4 functions:

a. main, one to read the data,
b.one to print them in the order read, and
c. one to print the compute

User Roxy
by
9.1k points

1 Answer

3 votes

Final answer:

The answer includes a Python program with four functions designed to read three integers and print them in both the original and reversed order, satisfying the student's request.

Step-by-step explanation:

The student has requested a program that can read three integers, then print them in the order they were read, as well as in reversed order. To accomplish this, we can write a program in a programming language such as Python that contains four functions as per the request: main(), read_data(), print_in_order(), and print_reversed(). Below is a simple example of such a program:

# Function to read data
def read_data():
return [int(input('Enter an integer: ')) for _ in range(3)]

# Function to print numbers in the order they were read
def print_in_order(numbers):
print('Numbers in order:', numbers)

# Function to print numbers in reversed order
def print_reversed(numbers):
print('Numbers reversed:', list(reversed(numbers)))

# Main function
def main():
numbers = read_data()
print_in_order(numbers)
print_reversed(numbers)

if __name__ == "__main__":
main()

This code asks the user to input three integers, stores them in a list, and then calls the appropriate functions to print the integers in both the original and reversed order.

User Hakan Kose
by
8.7k points