C Language Homework Tasks
C Language Homework Tasks
• In this homework, you are required to complete 10 tasks in the C language. Each
task involves writing a C program. The variables are predefined, so there is no need
to take input from the user.
• You should define any variables at the top of the program. After completing each
task, save the C code and sample output as one PDF and submit it. Make sure the
code is saved as text with a sample output for each task.
Example:
Side length = 5
Output:
*****
* *
* *
* *
*****
Example:
Rows = 5
Output:
1
11
121
1331
14641
Task 3: Hollow Right-Angled Triangle
Write a C program to print a hollow right-angled triangle pattern.
Define the side length as a variable at the top of the code.
Example:
Side length = 5
Output:
*
**
* *
* *
*****
Example:
Height = 4
Output:
1
23
456
7 8 9 10
Example:
Rows = 3
Output:
* * *
* * * *
* *
Task 6: Hollow Diamond Pattern
Write a C program to print a hollow diamond pattern.
Define the side length of the diamond as a variable at the top of the code.
Example:
Side length = 5
Output:
*
**
* *
* *
* *
* *
* *
**
*
Example:
Start = 1, End = 100
Output:
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
Example:
Number = 121
Output:
121 is a palindrome.
Task 9: Armstrong Number Checker
Write a C program to check if a predefined number is an Armstrong number.
Define the number at the top of the code.
153 = 13+53+33
Example:
Number = 153
Output:
153 is an Armstrong number.
Example:
Starting Number = 6
Output:
6 → 3 → 10 → 5 → 16 → 8 → 4 → 2 → 1
Number of steps: 8