Advertisement Remove all ads

Write a Program to Display Following Pattern: 1 232 34543 4567654 567898765 - Structured Programming Approach

Write a program to display following pattern: 

1
232
34543
4567654
567898765

Advertisement Remove all ads

Solution

Source code :
    #include 
    #include 
    void main( )
{
         int i, s, r, k=0, c=0, j=0;
         printf(“Enter the number of rows : “);
         scanf(“%d”, &r);
         for( i=1 ; i<=r ; i++ )
         {
             for( s=1 ; s<=r-i ; s++ )
             {
                prinf(“ ”);
                c++;
   }
   while( k != 2*i-1 )
   {
       if(c<=r-1)
       {
            printf(“%d”,(i+k));
            c++;
       }
       else
       {
           j++;
           printf(“%d”,(i+k-2*j));
     }
     ++k;

}
          j=c=k=0;
          printf(“\n”);
          }
    getch( );
}

Output : 

Enter the number of rows : 5
1
232
34543
4567654
567898765
  Is there an error in this question or solution?
Advertisement Remove all ads
Advertisement Remove all ads
Advertisement Remove all ads
Share
Notifications

View all notifications


      Forgot password?
View in app×