Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   I need Help of experts to solve this problem (http://www.go4expert.com/forums/i-help-experts-solve-t11528/)

Rajinder Kaur 21Jun2008 10:05

I need Help of experts to solve this problem
 
hello [:pleased:]
i have made a program but it didn't give required output [:shout:]
so plz help me to get required output........


i want to get output as

1 1
1 2 2 1
1 2 3 3 2 1
1 2 3 4 4 3 2 1
1 2 3 4 5 4 3 2 1


tell me... what will be the c program to solve this problem

with regards...

satveer.sm 23Jun2008 13:17

Re: I need Help of experts to solve this problem
 
Quote:

Originally Posted by Rajinder Kaur
hello [:pleased:]
i have made a program but it didn't give required output [:shout:]
so plz help me to get required output........


i want to get output as

1 1
1 2 2 1
1 2 3 3 2 1
1 2 3 4 4 3 2 1
1 2 3 4 5 4 3 2 1


tell me... what will be the c program to solve this problem

with regards...

Code:

              int j;
        for(int i = 1 ; i <= 5; i++)
        {
          for( j = 1 ; j <= i ;j++)
          {
         
            printf("%d ",j);
         
         
          }

          for( j = i ; j >= 1 ;j--)
          {
            if(j == 5 )
              continue;
            printf("%d ",j);
         
         
          }

          printf("\n\n");
       
        }



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