[c]Extension of previous triangle pattern with numbers

Get a mirror image of the pattern on previous post.
This exercise is the same as previous, just print the columns..

here’s the code:

#include <stdio.h>

int main()
{
    int num,rows,cols;
    printf("Enter the rows:");
    scanf("%d",&num);
    
    for(rows=1;rows<=num;rows++)
    {
        for(cols=1;cols=1;rows--)
    {
        for(cols=1;cols<=rows;cols++)
        {
               printf("%d",cols);
            
        }
        printf("\n");
    }
    
    return 0;
}

Looks like this when user enter 5:

Enter the rows:5
1
12
123
1234
12345
1234
123
12
1

Advertisements
This entry was posted in General stuffs. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s