Print Sequential Number Triangle
C++
Easy
2 views
Problem Description
Print numbers in sequential order (1,2,3...).
Real Life: Continuous counting in pattern.
Step-by-Step Logic:
1. Keep a counter starting from 1
2. Print counter value
3. Increment counter after each print
4. Continue across rows
Official Solution
void pattern_q5_sequential_numbers() {
int n = 5;
int counter = 1;
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= i; j++) {
cout << counter << " ";
counter++;
}
cout << endl;
}
}
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!