problem statement
Write a C program to print Floyds triangle. Floyd's triangle is a right angled-triangle using the natural numbers. Take the height as user input. Example of Floyd's triangle of height 4:
1
2 3
4 5 6
7 8 9 10
1
2 3
4 5 6
7 8 9 10
#include<stdio.h> int main() { int hght,temphght,temp,i; temp=temphght=1; printf("enter the hight \n"); scanf("%d",&hght); while(temphght<=hght) { for(i=0;i<temphght;i++) { printf("%d ",temp); temp++; } temphght++; printf("\n"); } return 0; }
No comments:
Post a Comment