Q. Write a program to generate a following numbers structure:
(Where user entered number through keyboard, for example if num=5)
55555
44444
33333
22222
11111
Ans.
int num,r,c;
printf("Enter loop repeat number(rows): ");
scanf("%d",&num);
for(r=num; r>=1; r--)
for(r=num; r>=1; r--)
{
for(c=num; c>=1; c--)
printf("%d",r);
printf("\n");
}
getch();
getch();
return 0;
}
/*************OUTPUT**************
Enter loop repeat number(rows): 5
***********************************/
/*************OUTPUT**************
Enter loop repeat number(rows): 5
55555
44444
33333
22222
11111
***********************************/
No comments:
Post a Comment