0% found this document useful (0 votes)
4 views2 pages

Computer Programming Assignment Tasks

Uploaded by

Yosef Kitaw
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Computer Programming Assignment Tasks

Uploaded by

Yosef Kitaw
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

HieLCoE

School of Computer Science and Technology


Computer Organization and Assembly Programming
Group Assignment II
General Instruction:
*Read the instructions and the questions carefully.

** Do the assignment questions independently at the group level

***Copying the answer of other group of students will nullify both parties.

Important Note
Method of Submission: e-mail-samuelgetachew34@[Link]

Date of Submission: December 30,2022

Date of Presentation: TBA

Assignment Questions
1. Write a program that determines the largest and the smallest of three numbers
accepting from user.
2. Develop a program that determines weather an input character is Uppercase or
not?
3. Write a program that accepts string from user and display its reverse.
4. Write a program that prints the factorial value of a number accepting from user.
5. Write a program that displays odd numbers between 0 and 50.
6. Write a program that calculates the average of three given numbers from user.
7. Write a program that converts a) user input value in Fahrenheit to Centigrade
(Celsius measuring scales).

Using the formula: Celsius = (Fahrenheit – 32 ) * 5 / 9

8. Write a program that arranges given n numbers in descending order


9. Write a program, which reads in decimal inputs repeatedly until a zero value is
entered; at this point, it should print out the sum of the numbers it reads so far.

1|Page
10. Write a program that accept a word from the user and finds weather it contains a
vowel or nor and show the result to the user.
11. Write a program that accept the name of the student and marks of subjects and
shows the maximum and minimum mark of a course that he has scored.
12. Write a program that decides weather the word is a palindrome or not accepting
the word from the user.

13. Write a program that computes and displays the sum, the difference and the
product of a range of consecutive numbers where the starting and ending
numbers of the range are to be entered from the keyboard.
14. Write a program that displays the upper and the lower cases of each of the Latin
alphabets as shown in the following example.
Example
Aa Bb Cc Dd . . . Zz.

15. Write a program that computes the square and cubed value of a number accepting
from the user.
16. Develop a program that accepts five numbers from user and sort in ascending
order.
17. Develop a program that shows Menu of a Restaurant for the user depending on
what he is interested in. (i.e if the person enters breakfast items available in that
day and time.)
18. Write a program that accepts name, age, sex, department and address from the
user and displays what has been entered as a result.
19. Write a program that accepts two numbers from user and finds the Great
Common Divisor of them.
20. Develop a program that accepts four numbers from the user and computes the
sum and difference of the minimum and maximum of numbers.

2|Page

Common questions

Powered by AI

First, the program should identify the maximum and minimum numbers among the four inputs, perhaps using max() and min() functions. It then calculates the sum (max + min) and the difference (max - min). A loop or conditional comparison can be used to determine these extremes if built-in functions are not employed .

To sort numbers in descending order, a sorting algorithm such as bubble sort, quicksort, or mergesort can be employed. The program should modify the comparison operator in the sorting logic to ensure greater elements precede smaller ones. Considerations include choice of algorithm based on time complexity (e.g., quicksort's average O(n log n)) and implementation ease .

To determine if a word is a palindrome, a program should compare the word with its reverse. If both strings are identical, the word is a palindrome. This can be achieved by iterating half the length of the string and comparing characters from the start and end towards the center, or more simply, by reversing the string and checking equality. For example, in Python, you could use `if word == word[::-1]:` to verify .

To determine the largest and smallest numbers among three inputs, a program can use a series of conditional checks. Compare each number against the others using if-else structures to track the largest and smallest values during comparisons. Alternatively, the program can store the numbers in a list and use built-in functions like max() and min() for simplicity .

The program should prompt for user input and store the number. It then calculates the square by raising the number to the power of two (using the exponentiation operator `**` or a multiplication operation) and the cube by similarly raising it to the third power. The results are displayed to the user .

To convert a temperature from Fahrenheit to Celsius, the program should apply the formula Celsius = (Fahrenheit - 32) * 5/9. The program should first subtract 32 from the Fahrenheit value, and then multiply the result by 5/9 to get the Celsius representation. This ensures an accurate conversion by following established mathematical computations .

The Euclidean algorithm is an efficient method for finding the GCD. The algorithm repeatedly replaces the larger number by the remainder when the larger number is divided by the smaller one. This process continues until the remainder is zero, and the last non-zero remainder is the GCD. This algorithm can be implemented using either iteration or recursion .

A loop structure such as a 'for' loop can iterate from 0 to 50, using a conditional statement to check for odd numbers (`if i % 2 != 0:`). Each passing iteration satisfying the odd condition is printed. The program can also increment by 2 starting from 1 to achieve the same result efficiently .

An algorithm to calculate a factorial should use a loop or recursion. Starting with an accumulator set to 1, a loop can iterate from 1 up to the number, multiplying the accumulator by each number. Alternatively, recursion can call the factorial function with decremented values until 1 is reached. Both methods require conditional checks and either iterative or recursive structure .

To detect vowels in a string, iterate through each character and compare against a list of vowels ('a', 'e', 'i', 'o', 'u'). A boolean flag can be used to mark the presence of vowels after any match. Alternatively, the program can convert the string to lowercase and use regular expressions for pattern matching .

You might also like