Q. Write a C program to make a diagonal number pattern as following design:
1
2
3
4
5
Ans.
/* c program source code for diagonal number pattern*/
#include<stdio.h>
int main()
{
int num,r,c,sp;
printf("Enter total no. rows : ");
scanf("%d", &num);
for(r=1; r<=num; r++)
{
for(sp=r; sp<num; sp++)
printf(" ");
printf(" %d\n",r);
}
getch();
return 0;
}
You might also like to read:
1
2
3
4
5
Ans.
/* c program source code for diagonal number pattern*/
#include<stdio.h>
int main()
{
int num,r,c,sp;
printf("Enter total no. rows : ");
scanf("%d", &num);
for(r=1; r<=num; r++)
{
for(sp=r; sp<num; sp++)
printf(" ");
printf(" %d\n",r);
}
getch();
return 0;
}
/***************************************************
The output of above program would be:
***************************************************/
Figure: Screen shot for Diagonal Number Pattern In C Output |
You might also like to read:
No comments:
Post a Comment