Pages

Monday 21 July 2014

Write a program to generate a following numbers structure:

(Where user entered number through keyboard, for example if num=5)
                            11111
                            22222
                            33333
                            44444
                            55555

Ans.


#include<stdio.h>
int main()
{
 int num,r,c;
 printf("Enter loop repeat number(rows): ");
 scanf("%d",&num);
 for(r=1; num>=r; r++)
 {
  for(c=num; c>=1; c--)
     printf("%d",r);
  printf("\n");
 }
 return 0;
}

/*************OUTPUT****************
Enter loop repeat number(rows): 5

                            11111
                            22222
                            33333
                            44444
                            55555

************************************/

0 comments:

Post a Comment