use only 2or3 variable i.e. i,j,k in for loop

output

1

2 2

3 3 3

4 4 4 4

5 5 5 5 5

use only 2or3 variable i.e. i,j,k in for loop

output

1

2 2

3 3 3

4 4 4 4

5 5 5 5 5

1 Like

home work questions ?

I hope this will help youâ€¦

#include

int main()

{

int i, j, k, c = 5;

for (i = 1; i <= 5; i++)

{

/* k is taken for spaces */
for (k = 1; k <= c; k++)
{
/* blank space

printf(" ");

}

for (j = 1; j <= i; j++)

{

/

printf("%2d", i);

}

printf("

");

/*c is decremented by 1 */

câ€“;

}

return 0;

}

#include

void main()

{

int i,j,k,n;

printf(â€śenter nâ€ť);

scanf("%d",&n);

for(i=1;i<=n;i++)

{

for(k=1;k<=n-i;k++)

printf("");

for(j=1;j<=i;j++)

printf("%2d",i);

printf("

");

}

}

output:

enter n:5

1

22

333

4444

55555