Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Assignment 3 Part 1

Task 1: Write a program that asks user how many number he wants to enter. It also asks for which number the
user wants to check the multiple. The program then inputs that many numbers and tells if the given number is
multiple of the other number or not.
Example:
How many numbers you want to enter: 4
Which number you want to check multiple for: 3
Enter number 1: 3, yes multiple of 3
Enter number 2: 5, not multiple of 3
Enter number 3: 2, not multiple of 3
Enter number 4: 9, yes multiple of 3

Task 2: Write a program which will take a number from user and print the number in reverse order.
Sample Input: 12345
Output: 54321

Task 3: Write and run a program that reads a six-digit integer and prints the sum of its six digits.
Sample Input: 153426
Sample output: 21

Task 4: Write and run a program which takes a number, and tells if it is a palindrome or not. For a reference, a
palindrome is a number which is read the same from both sides. For example 19391 is a palindrome, because,
if we read it from the right, or from the left, it remains same. However, 12368 is not a palindrome, because, if
you read it from left, it is another number, and if you read it from right, it is another number

Sample Input: 651432


Not a palindrome

Sample Input: 651156


Palindrome

Task 5: Ask user to enter a number. Check if that number is a prime number or not.

Sample Input: 12
Not a prime number

Sample Input: 17
prime number

Task 6: Ask user to enter a number. Check if that number is a perfect square or not.

Sample Input: 12
Not a perfect square

Sample Input: 25
Perfect square
Task 7: Ask user to enter 5 numbers one by one. Find sum of even and odd numbers in separate variables?
Create the following functions;

Task 8: Ask user to enter 5 numbers one by one. Find how many positive numbers are entered.
Simultaneously, calculate product of given positive numbers? Create the following functions;

Task 9: Ask user to enter 5 numbers one by one. Find how many positive and even numbers are entered.
Simultaneously, calculate sum of given positive even numbers? Create the following functions;

Task 10: Take two numbers from user; say start and end. Find the sum of all number from start to end that
are divisible by 3. Display the sum on console. Create the following functions;

Task 11: Take two numbers from user; say start and end. Find the sum of all number from start to end that
are divisible by 3 and are even. Display the sum on console. Create the following functions

Task 12: Write a program which will take at max: a six digit number and output each of its digit in words.
Sample Input: 234156
Output: Six Five One Four Three two

Task 13: Write a program which will take at max: a six digit number and output each of its digit in words.
Sample Input: 651432
Output: Six Five One Four Three two

You might also like