Q. Write a C program to make the following number pattern triangle program as:
10 9 8 7 6 5 4 3 2 1 0
10 9 8 7 5 3 2 1 0
10 9 8 5 2 1 0
10 9 5 1 0
10 5 0 5
Ans:
/*c program for number pattern program*/
#include<stdio.h>
int main()
{
int num=6,r,c,n,p;
n=num;
for(r=1; r<=num; r++,n++)
{
for(c=10; c>=n; c--)
printf(" %d", c);
printf(" 5");
for(c=num-r-1; c>=0; c--)
printf(" %d", c);
printf("\n");
}
getch();
return 0;
}
No comments:
Post a Comment