Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   number pattern (http://www.go4expert.com/forums/number-pattern-t24127/)

programmerg 9Dec2010 10:31

number pattern
 
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

xpi0t0s 9Dec2010 19:51

Re: number pattern
 
Easy. Where are you stuck?

virxen 10Dec2010 03:53

Re: number pattern
 
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;
}



All times are GMT +5.5. The time now is 06:06.