COMSATS University Islamabad Sahiwal Campus
(Department of Computer Sciences)
Course Title: Programming Course CSC103 Credit 3
Course Anam Khan Programme BS
Semester: 2nd Batch Fa23 Sectio A,B Date: 03-25-2024
Time Allowed: : n: Maximum Marks: 25
Student’s Reg. CUI/
Name:
Important Instructions / Guidelines: No. /SWL
Please upload your hard copy on due date.
Ensure your name, student ID are clearly mentioned on the
assignment.
Late submissions will be subject to a penalty.
Plagiarism will result in severe academic consequences, as outlined
in the university's academic integrity policy.
Assignment #02
1. Write a program in C++ to display a pattern like a right-angle triangle using
an asterisk.
Sample Output:
Input number of rows: 5
*
**
***
****
*****
2. Write a C++ program that makes a pattern such as a right angle triangle
using numbers that repeat.
Sample Output:
Input number of rows: 5
1
22
333
4444
55555
3. Write a C++ program to make such a pattern like a pyramid with numbers
increased by 1.
Sample Output:
Input number of rows: 4
1
23
456
7 8 9 10
4. Write a C++ program to display a pattern like a diamond.
Sample Output:
Input number of rows (half of the diamond): 5
*
***
*****
*******
*********
*******
*****
***
*
5. Write a C++ program to display Pascal's triangle like a right angle triangle.
Sample Output:
Input number of rows: 7
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
1 5 10 10 5 1
1 6 15 20 15 6 1
6. Write a C++ program to print a pattern in which the highest number of
columns appears in the first row.
Sample Output:
Input the number of rows: 5
12345
2345
345
45
5
7. Write a C++ program that displays the pattern with the highest columns in
the first row and digits with the right justified digits.
Sample Output:
Input number of rows: 5
12345
1234
123
12
1
8. Write a C++ program to display Pascal's triangle like a pyramid.
Sample Output:
Input number of rows: 5
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1