Here you are:
#include <stdio.h>
#include <string.h>
int main( void )
{
const char *s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const size_t N = strlen(s);
while (1)
{
printf("Enter a non-negative number (0 - exit): ");
size_t n;
if (scanf("%zu", &n) != 1 || n == 0) break;
size_t k = 0;
for (size_t i = 0; i < n; i++)
{
for (size_t j = 0; j <= i; j++)
{
printf("%c", s[ k++ % N ]);
}
putchar('\n');
}
}
return 0;
}
The program output might look like:
Enter a non-negative number (0 - exit): 12
A
BC
DEF
GHIJ
KLMNO
PQRSTU
VWXYZAB
CDEFGHIJ
KLMNOPQRS
TUVWXYZABC
DEFGHIJKLMN
OPQRSTUVWXYZ
Enter a non-negative number (0 - exit): 0
2
solved C Primer Plus 6th ed chapter 6 programming exercise 4