for n=5;
1
3 5
8 11 14
18 22 26 30
35 40 45 50 55
code is below:
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <stdlib.h>
int main()
{
int num;
int k = 0;
printf("Enter the number\n");
scanf("%d", &num);
for (int i = 1; i <= num; i++)
{
for (int j = 1; j <= (num * 2) - 1; j++)
{
if (j <= i)
{
k = k + i;
printf("%d ", k);
}
else
{
printf(" ");
}
}
printf("\n");
}
return 0;
}
Comments
Post a Comment