Menu BAR

FEEL FREE TO ASK ANY PROGRAM and please mention any error if you find it

15 Jan 2013

Number pyramid 1

 Q.) Write a program to print the following number pyramid:

1
123
12345
1234567      

Sol)

#include<stdio.h>

int main()
int num, r, c, p=1;

printf("Enter the number of rows: ");

scanf("%d", &num) ;

for(r=1; r<=num; r++,p=p+2)
{
   for(c=1; c<=p; c++)
      {
        printf("%d",c) ;
       }
   printf("\n") ;
}

return 0 ;

}

No comments:

Post a Comment