\(\begin{array}{cccccc}1&2&3&4&5&6\\2&3&4&5&6&7\\3&4&5&6&7&8\\4&5&6&7&8&9\\5&6&7&8&9&0\\ 6&7&8&9&0&1\end{array}\)
Write a program that reads a number of liines and displays the above pattern.
Difficulty level
This exercise is mostly suitable for students
#include<stdio.h>
#include<conio.h>
void main()
{
int N, i, j;
do{
printf("Enter N: ");
scanf("%d",&N);
}while(N<=0);
for(i=1; i<=N; i++)
{
for(j=i; j < i+N; j++)
printf("%d", j%10);
printf("\n");
}
getch();
}
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Implement a stack using a heap