/*
Q.    Write a C program to print the following output using for loop.
1
2 2
3 3 3
4 4 4 4

*/

#include<stdio.h>

main()
{
    int i,j,n;
    printf("\nEnter line number=");
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=i;j++)
        {
            printf("%d ",i);
        }
        printf("\n");
    }
}

No comments:

Post a Comment