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

Practice Questions 2 4 5

The document contains a practice set with programming tasks that include printing patterns, calculating factorials, checking for strong and Armstrong numbers, validating phone numbers, and finding twin primes. It also includes a menu-driven program for GCD, LCM, and prime checking. Each task specifies input requirements and expected output formats.

Uploaded by

b25ci1054
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)
20 views2 pages

Practice Questions 2 4 5

The document contains a practice set with programming tasks that include printing patterns, calculating factorials, checking for strong and Armstrong numbers, validating phone numbers, and finding twin primes. It also includes a menu-driven program for GCD, LCM, and prime checking. Each task specifies input requirements and expected output formats.

Uploaded by

b25ci1054
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/ 2

Practice Set 2

1.​ Write a program to print the following pattern. Take a number of lines as input. For
example, for input 5 the output is shown below:
1
11
111
1111
11111

2.​ Write a program to print the factorial of a number which is taken as input. Remember, the
input can be anything between 1-100.
3.​ Given a number, check whether it is a strong number or not. A strong number is a
special number, such that the sum of the factorials of all digits present in the number
should be equal to the number itself.
4.​ Write a program to check whether a 3-digit number follows the given property or not. If
the number follows it, print “Yes”, otherwise print “No”.
Property: the sum of cubes of each digit is less than the number
Example: 111 follows the given property as (1*1*1 + 1*1*1 + 1*1*1) < 111

5.​ 11. Check if the input phone number p is valid or not. A phone number is valid if,
a.​ It contains 10 digits
b.​ It may contain 11 digits, but in that case the first digit should be 0
c.​ The starting digit should be either 9, 8 or 7
Take p as input and output 1 if the phone number is valid else output 0.
6.​ Write a C program to check if a given number is an Armstrong number.

Example: 153 → 1³ + 5³ + 3³ = 153

7.​ Write a C program to print all twin prime pairs between 1 and 100.

Twin primes are pairs of prime numbers that differ by 2.

Example: (3,5), (5,7), (11,13), (17,19)...

8.​ Write a C program that repeatedly displays a menu and performs the selected operation
using a switch statement.
Menu:
1. Find GCD of two numbers
2. Find LCM of two numbers
3. Check if a number is Prime
4. Exit
9.​Write a C program to print the following pattern for a given number of rows n.

Example: For n = 5, the output should be:

10.​Write a C program to print the following pattern for a given number of rows n.

Example: For n = 5, the output should be:

*****

****

***

**

**

***

****

*****

You might also like