number pattern

programmerg's Avatar, Join Date: Dec 2010
Newbie Member
print this pattern using for loop.

1 2 3 4
5 6 7
8 9
10
10
9 8
7 6 5
4 3 2 1
0
xpi0t0s's Avatar, Join Date: Aug 2004
Mentor
Easy. Where are you stuck?
0
virxen's Avatar, Join Date: Nov 2009
Pro contributor
can you figure out the last step?

Code:
#include <stdio.h>

int main(){
    int i;
    for (i=0;i<20;i++){
        if (i<10)
            printf("%d ",i+1);//straight
        else
            printf("%d ",20-i);//reverse
    }
    
    getchar();
    return 0;
}