Homework No. 2

[Basic Control Flow, Loops]
For your number, check here.

Write a program that
 
(0) reads a
sequence of floating-point data values from the input, and prints out the average (arithmetic mean) of the data [P4.8].

(1) reads a
sequence of strings and prints out the longest of them.

(2) reads a word and prints out "PALINDROME", if it a palindrome, i.e. a word, that reads the same backward or forward.

(3) reads two natural numbers and prints out their greatest common divisor.

(4) reads two natural numbers and prints out
their least common multiple.

(5) reads two strings and prints out yes, if the second string is a substring of the first and no, otherwise.

(6) reads a positive number n and prints out all prime numbers, less than or equal to n [P4.20].


(7) reads a positive integer N and prints the sum of this number and the number generated by the digits of N in backward order.

(8) reads a natural number n and prints out the sum: 1 + 2.3 + 3.4.5 + 4.5.6.7 +...+ n.(n + 1)...(2n - 1).

(9) reads a natural number n and prints out the sum of the prime divisors of n.

(10) reads two words and prints out "YES", if the second word is made by transposing the letters of the first word (anagram).

(11) reads a string and prints out all repeating (at least twice) symbols in it.

(12) reads a positive number and prints out all its divisors.

(13) reads a positive number n and prints out first n numbers (from the sequence 1,2,3,4,5,...) which are divisible by 2, 3 and 5.

(14) reads two natural numbers a and b and prints out the number of digits of ab (the product of a and b).

(15) reads a positive number n and prints out a list of all perfect numbers (are equal to the sum of all of their factors), less than n.

(16) reads two strings and prints out "YES", if the second string contains only characters of the first string (example: "aaabb" and "a" - YES).

(17) reads a sequence of words and prints them out in reverse order of their letters (example: "print" as "tnirp").

(18) reads a
sequence of positive numbers and prints out their binary numeral system representations [P4.16].

(19) reads a
sequence of positive numbers and prints out their octal number base system representations.

(20) reads two positive integers a and b (a < b) and prints out the count of integer numbers in the interval [a,b], which have no the same digits (example:  in the interval [110,124] there are 3 such numbers - 120,123,124).

(21) reads a sequence of strings of ones and zeros and prints out the numbers (in decimal system), whose binary system representations are these strings.

(22)
reads two strings and prints out yes, if the second string is a prefix of the first and no, otherwise.

(23)
reads two strings and prints out yes, if the second string is a subsequence of the first and no, otherwise.

(24) reads two strings and prints out yes, if the second string is a suffix of the first and no, otherwise.

(25) reads a sequence of integer inputs and prints the smallest and largest of the inputs [P4.2a].

(27)
reads a sequence of integer inputs and prints the number of even and odd inputs [P4.2b].

(28)
reads a sequence of integer inputs and prints all adjacent duplicates (for example, if the input is 1 3 3 4 5 5 6 6 2, the program should print 3 5 6) [P4.2d].

(29) reads a line of input as a string and prints only the uppercase letters in the string [P4.3a].

(30)
reads a line of input as a string and prints every second letter of the string [P4.3b].

(31) reads a line of input as a string and prints the string, with all vowels replaced by an underscore [P4.3c].

(32)
reads a line of input as a string and prints the number of vowels in the string [P4.3d].

(33) reads a line of input as a string and prints the positions of all vowels in the string [P4.3e].

(34) [P4.5], p.179.

(35) [P4.14], p.180.

(36) reads a word and prints all substrings, sorted by length (for example, if the user provides the input "rum", the program prints r, u, m, ru, um, rum) [P4.15].

(37) [P4.17], p.181.

(38) [P4.25], p.183.

(39) [P4.26], p.183.

(40) asks the user for an integer and then prints out all its factors (for example, when the user enters 150, the program should print 2, 3, 5, 5) [P4.19].

(41)
[P4.22], p.182.

(42)
[P4.23], p.182.

(43)
[P4.27], p.183.