3.26.2013

Double Number Triangle

Q. Write a C program to print the following number design as:

1
11
2222
333333
44444444
5555555555

Ans.

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

The output of above program would be:


Output of double number pyramid C program
Figure: Screen shot for double number pyramid C program

No comments:

Post a Comment