Tweet
Share
COMPUTER PROGRAMMING
HOME
Quadratic equation
Floids Triangle
Fibonacci series & Prime numbers
Merge Sorting
Stack in an array
Two Stacks in an array
Tweet
Share
C PROGRAMMING QUESTIONS AND ANSWERS WITH ALGORITHM
3.Write C Program to print Floids Triangle?
1
2 3
4 5 6
7 8 9 10
ALGORITHM
Step 1:start
Step 2:Declare variables i,j,count=1,lim.
Step 3:Input the Limit of the Floids Triangle.
Step 4:Read the Limit.
Step 5:Initialize i=0
Step 6:while(i<=lim) repeat steps 6.1 to 6.5
6.1)Initialize j=0
6.2)while(j<i) repeat steps a to b
a)Print the count,%3d, 3 denotes space between two numbers.
b)Increment count by 1.
c)Increment j by 1.
6.3)End while.
6.4)Print new line.
6.5)Increment i by 1.
Step 7:End while
Step 8:Stop.
PROGRAM
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,count=1,lim;
clrscr();
printf("Enter the limit :");
scanf("%d",&lim);
for(i=0;i<=lim;i++)
{
for(j=0;j<i;j++)
{
printf("%3d",count);
count++;
}
printf("\n");
}
getch();
}
OUTPUT
Enter the limit :4
1
2 3
4 5 6
7 8 9 10
First
<<Previous
Next>>