1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

I need Help of experts to solve this problem

Discussion in 'C' started by Rajinder Kaur, Jun 21, 2008.

  1. Rajinder Kaur

    Rajinder Kaur New Member

    Joined:
    Jun 21, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    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...
     
  2. satveer.sm

    satveer.sm New Member

    Joined:
    Nov 23, 2007
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    software engineer
    Location:
    noida
    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");
    	
    	}
     
    Last edited by a moderator: Jun 23, 2008

Share This Page