Showing posts with label Numbers rectangle pyramid. Show all posts
Showing posts with label Numbers rectangle pyramid. Show all posts

Thursday, September 1, 2011

9.Design numbers rectangle structure

Q. 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

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

8.Design numbers rectangle structure

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.

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

                            55555
                            44444
                            33333
                            22222
                            11111

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

7.Design numbers rectangle structure

Q. Write a program to generate a following numbers structure:
   (Where user entered number through keyboard, for example if num=5)

                                54321
                                54321
                                54321
                                54321
                                54321

Ans.

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

                                54321
                                54321
                                54321
                                54321
                                54321

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

6.Design numbers rectangle structure

Q. Write a program to generate a following numbers structure:
   (Where user entered number through keyboard, for example if num=5)

                        12345
                        12345
                        12345
                        12345
                        12345

Ans.

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

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

                        12345
                        12345
                        12345
                        12345
                        12345

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