How to print ladder in C ?

Little explanation->Programmer should use ‘character’ value to print the ladder in c program.
#include<stdio.h>
int main ()
{
int i,j,k,n;
printf(“Enter value of N\n”);
scanf(“%d”,&n);
for(i=1;i<=n;i++)
{
for(j=1;j<=2*n-i;j++)
printf(” “);
for(k=1;k<=2*i-1;k++)
printf(“%C”,k);
printf(“\n”);
}
}

Output of program –

Leave a Reply