Print p lines of q numbers in sequence starting from 1
Print p lines of q numbers in sequence starting from 1
Write a C program that reads two integers p and q, prints p number of lines in a sequence of 1 to b in a line.
Sample Solution:
C Code:
Sample Output:
Input number of lines: 5 Number of numbers in a line: 6 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
Flowchart:

For more Practice: Solve these Related Problems:
- Write a C program to print a p x q matrix of sequential numbers, where the numbers in each row are in reverse order.
- Write a C program to display a p x q grid with alternating row orders (one row ascending, the next descending).
- Write a C program to print a rectangular matrix where each row starts with the next consecutive number from the previous row.
- Write a C program to generate a matrix starting from a user-defined number and fill it with sequential numbers with a fixed increment.
C programming Code Editor:
Previous: Write a C program to print a number, it’s square and cube in a line, starting from 1 and print n lines. Accept number of lines (n, integer) from the user.
Next: Write a C program to calculate the average marks of mathematics of some students. Input 0 (excluding to calculate the average) or negative value to terminate the input process.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.