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

Week10_exercise

The document outlines ten programming tasks including calculating the angle between clock hands, finding the last non-zero digit of a factorial, checking for nearly prime numbers, analyzing multi-line input for character and word counts, generating sequences of odd and even numbers based on input parity, producing unique digit combinations that sum to a target, summing positive integers from sentences, creating a full pyramid of alphabets, calculating time period differences, and removing symbols while retaining alphabets.

Uploaded by

Evanie
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)
2 views

Week10_exercise

The document outlines ten programming tasks including calculating the angle between clock hands, finding the last non-zero digit of a factorial, checking for nearly prime numbers, analyzing multi-line input for character and word counts, generating sequences of odd and even numbers based on input parity, producing unique digit combinations that sum to a target, summing positive integers from sentences, creating a full pyramid of alphabets, calculating time period differences, and removing symbols while retaining alphabets.

Uploaded by

Evanie
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
You are on page 1/ 3

1. Input time, and find the angle between hour hand and minute hand of a clock.

2. Determine the last non-zero digit of the factorial of a given positive


integer. For instance, input 5, the factorial is 5! = 120, and the last non-zero
digit of 120 is 2. Hence, the output should be 2.

3. Check if an input number is a nearly prime number, which means the product
of two prime numbers.

4. Write a program that accepts a multi-line input string (terminated by


EOF) and performs the following tasks:
a. Count the total number of characters (including spaces and
punctuation).
b. Count the number of words (defined as sequences of characters
separated by spaces or punctuation).
c. Count the number of lines (separated by newline characters).

5. Accept an integer n as input, where n can be either odd or even.If n is even,


print the next 10 odd numbers first, followed by the next 10 even numbers. If n
is odd, print the next 10 even numbers first, followed by the next 10 odd
numbers.

6. Accept 2 integers n and s, n states for the number of digits available (chosen
from 0 to 9), s states for the target sum that needs to be achieved. The
program should print all unique combinations of the n digits (without
repetition) where the sum of the selected digits equals the given target s. The
program should not use any digit more than once in a combination. The
output should include all such unique combinations where the sum of the
digits equals s.
7. Reads sentences containing positive integers embedded in them and
calculates the sum of all the numbers. The program should be able to
process multiple lines of input, where each line may contain digits, letters,
symbols, or spaces. The program must extract all the digits (positive integers)
from the sentences and compute their total sum. Note that the digits in the
sentence are consecutive and do not have any separators, so the program
should correctly identify and sum up the numbers.

Sample Input: 123abc456def789

Sample output: 1368

8. Full Pyramid of Alphabets:


9. Count time period difference:

10. Remove symbol but keep alphabet:

You might also like