0% found this document useful (0 votes)
36 views4 pages

The University of Lahore, CS&IT Department: Programming Fundamentals1 Assignment: Simple Repetition Structures

The document provides instructions for an assignment on simple repetition structures in C++ for a Programming Fundamentals 1 course. Students are asked to complete 14 programming problems involving calculations with digits, factors, and series. The problems cover topics like calculating sums of digits, reversing numbers, checking for palindromes, finding digit frequencies, writing numbers in words, finding factors and prime factors, calculating HCF and LCM, checking for prime, Armstrong, perfect, strong and Fibonacci numbers. The deadline for email submission of the program codes and output is December 05, 2018.

Uploaded by

Ali Ashraf
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)
36 views4 pages

The University of Lahore, CS&IT Department: Programming Fundamentals1 Assignment: Simple Repetition Structures

The document provides instructions for an assignment on simple repetition structures in C++ for a Programming Fundamentals 1 course. Students are asked to complete 14 programming problems involving calculations with digits, factors, and series. The problems cover topics like calculating sums of digits, reversing numbers, checking for palindromes, finding digit frequencies, writing numbers in words, finding factors and prime factors, calculating HCF and LCM, checking for prime, Armstrong, perfect, strong and Fibonacci numbers. The deadline for email submission of the program codes and output is December 05, 2018.

Uploaded by

Ali Ashraf
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/ 4

The University of Lahore, CS&IT Department

Programming Fundamentals1

Assignment: Simple Repetition Structures

Instructions:
Students can do assignment in pairs but avoid cross group plagiarism (copying), it will get caught
eventually.
Deadline: December 05, 2018 11:59 PST.
Submission mode: Email the final single .doc report containing all the codes and screen shots of output
as well as the .cpp files of each program in a compressed folder with the clear subject:
“PF1/Ass#2/Section/Rollnumber1/Rollnumber2” at [email protected]. Emails without this
format will not be marked.

1. Write a C++ program to calculate sum of digits of a number.


Example
input
Input any number: 1234
Output
Sum of digits: 10

2. Write a C++ program to enter a number and print its reverse.


Example
Input
Input number: 12345
Output
Reverse of 12345 = 54321

3. Write a C++ program to check whether a number is palindrome or not.


(Palindrome number is such number which when reversed is equal to the original number. For example:
121, 12321, 1001 etc.)
Example
Input
Input any number: 121
Output
121 is palindrome
4. Write a C++ program to find frequency of each digit in a given integer.
Example
Input
Input any number: 116540
Output
Frequency of 0 = 1
Frequency of 1 = 2
Frequency of 2 = 0
Frequency of 3 = 0
Frequency of 4 = 1
Frequency of 5 = 1
Frequency of 6 = 1
Frequency of 7 = 0
Frequency of 8 = 0
Frequency of 9 = 0

5. Write a C++ program to enter a number and print it in words.


Example
Input
Input number: 1234
Output
One Two Three Four

6. Write a C++ program to find all factors of a number.


Example
Input
Input number: 12
Output
Factors of 12: 1, 2, 3, 4, 6, 12

7. Write a C++ program to find HCF (GCD) of two numbers.


Example
Input
Input first number: 12
Input second number: 30
Output
HCF of 12 and 30: 6

8. Write a C++ program to find LCM of two numbers.


Example
Input
Input number1: 12
Input number2: 30
Output
LCM = 60

9. Write a C++ program to check whether a number is Prime number or not.


Example
Input
Input any number: 17
Output
17 is prime number

10. Write a C++ program to find all prime factors of a number.


Example
Input
Input any number: 10
Output
Prime factors of 10: 2, 5

11. Write a C++ program to check whether a number is Armstrong number or not.
(An Armstrong number is a n-digit number that is equal to the sum of the nth power of its digits. For
example -
1
6=6 =6
3 3 3
371 = 3 + 7 + 1 = 371)
Example
Input
Input number: 371
Output
371 is armstrong number

12. Write a C++ program to check whether a number is Perfect number or not.
(Perfect number is a positive integer which is equal to the sum of its proper positive divisors.
For example: 6 is the first perfect number
Proper divisors of 6 are 1, 2, 3
Sum of its proper divisors = 1 + 2 + 3 = 6.
Hence 6 is a perfect number.)
Example
Input
Input any number: 6
Output
6 is PERFECT NUMBER

13. Write a C++ program to check whether a number is Strong number or not.
(Strong number is a special number whose sum of factorial of digits is equal to the original number.
For example: 145 is strong number. Since, 1! + 4! + 5! = 145)
Example
Input
Input number: 145
Output
145 is STRONG NUMBER

14. Write a C++ program to print Fibonacci series up to n terms.


(Fibonacci series is a series of numbers where the current number is the sum of previous two terms. For
Example: 0, 1, 1, 2, 3, 5, 8, 13, 21, ... , (n-1th + n-2th))
Example
Input
Input number of terms: 10
Output
Fibonacci series:
0, 1, 1, 2, 3, 5, 8, 13, 21, 34

You might also like