# include <stdio.h>
# include <conio.h>
void main()
{
int r, i, j, c = 1 ;
clrscr() ;
printf("Enter the number of rows : ") ;
scanf("%d", &r) ;
printf("\nFloyd's triangle is : \n\n") ;
for(i = 0 ; i < r ; i++)
{
for(j = 0 ; j <= i ; j++)
{
printf("%-6d", c) ;
c++ ;
}
printf("\n\n") ;
}
getch() ;
}
RUN 1 :
~~~~~~~
Enter the number of rows : 5
Floyd's triangle is :
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
# include <conio.h>
void main()
{
int r, i, j, c = 1 ;
clrscr() ;
printf("Enter the number of rows : ") ;
scanf("%d", &r) ;
printf("\nFloyd's triangle is : \n\n") ;
for(i = 0 ; i < r ; i++)
{
for(j = 0 ; j <= i ; j++)
{
printf("%-6d", c) ;
c++ ;
}
printf("\n\n") ;
}
getch() ;
}
RUN 1 :
~~~~~~~
Enter the number of rows : 5
Floyd's triangle is :
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
No comments:
Post a Comment