WAP to Generate Floyd's Triangle in C - 49
This program print's the generated Floyd's Triangle in C.
Program Code:
/* Program to generate Floyd's triangle. */ #include<stdio.h> int main() { int idx, jdx, num, val = 1; /* get the number of rows for the triangle */ printf("Enter a Value of N : "); scanf("%d", &num); /* prints right angled triangle using nos 1 to x */ for (idx = 1; idx <= num; idx++) { for (jdx = 1; jdx <= idx; jdx++) { /* prints the data */ printf("%3d", val++); } printf("\n"); } return 0; }
Post a Comment