Write a c program for Floyd’s triangle.






1. Write a c program to print Floyd’s triangle

2. C program to display Floyd’s triangle

3. How to print Floyd’s triangle in c


#include<stdio.h>



int main(){

  int i,j,r,k=1;

  printf("Enter the range: ");
  scanf("%d",&r);

  printf("FLOYD'S TRIANGLE\n\n");
  for(i=1;i<=r;i++){
      for(j=1;j<=i;j++,k++)
           printf(" %d",k);
      printf("\n");
  }

  return 0;
}

Sample output:
Enter the range: 10
FLOYD'S TRIANGLE

 1
 2 3
 4 5 6
 7 8 9 10
 11 12 13 14 15
 16 17 18 19 20 21
 22 23 24 25 26 27 28
 29 30 31 32 33 34 35 36
 37 38 39 40 41 42 43 44 45
 46 47 48 49 50 51 52 53 54 55





What is Floyd’s triangle?

Definition of floyd's triangle:

Floyd's triangle is a right angled-triangle using the natural numbers. Examples of floyd's triangle:

Example 1:

1
2 3
4 5 6
7 8 9 10

Example 2:

1
2   3
4   5   6
7   8   9   10
11  12  13  14  15
16  17  18  19  20 21





10. Write a c program to add two numbers without using addition operator.
11. Write a c program to subtract two numbers without using subtraction operator.
15. Write a c program to solve quadratic equation.
18. Write a c program which passes structure to function.
28. Write a c program which takes password from user.
29. Write a scanf function in c which accept sentence from user.
30. Write a scanf function in c which accept paragraph from user.

71 comments:

Anonymous said...

poda dai

Anonymous said...

Write a C program to generate the below pattern of letters:
A B C D E F F E D C B A
A B C D E E D C B A
A B C D D C B A
A B C C B A
A B B A
A A

Nishu said...

4
4 3 4
4 3 2 3 4
4 3 2 1 2 3 4
4 3 2 3 4
4 3 4
4

plz send this diagram coding

Anonymous said...

wot i do to make my programming strong

siya rose said...

thanku very much

prembaboo said...

int main()
{
char *c="ABCDEF";
char *c1="FEDCBA";
int i,j=0;
for(i=6;i>0;i--)
{
printf("%*.*s",i,i,c);
printf("%*.*s\n",i,i,c1+j);
j++;
}
getch();
}
by Prem baboo

triangle said...

1
2 6
120 240 720

bala said...

* *
** **
*** ***
*******


pls send the diagram coding

Anonymous said...

hai,i want this code,could you send me

Anonymous said...

can you send me this program?

Anonymous said...

best website to learn c programming and c graphics. Just visit www.programmingcampus.com

Unknown said...

what happens if return 0 is not there

Unknown said...

ABCDCBA
ABC CBA
AB BA
A A

please help me to solve this sequence

Anonymous said...

how to print
54321
5432
543
54
5

Anonymous said...

how to print
55555
4444
333
22
1

Anonymous said...

i want the code for construct the structure of "A" with the help of *

Anonymous said...

#include
#include
main()
{
int n,i,j,m;
clrscr();

printf("\n\nEnter any number=>");
scanf("%d",&n);
m=n;


for(i=1; i<=n; i++)
{
for(j=m; j>=1; j--)
{
printf("\t%d",m);
}
m--;
printf("\n");
}

getch();
return 0;
}

Unknown said...

#include
int main()
{
int r,i,j,m;
printf("Enter any number:\n");
scanf("%d",&r);
m=r;
for(i=1; i<=n; i++)
{
for(j=m; j>=i; j--,m--)
{
printf("%d\t",m);
}
m=r;
printf("\n");
}
return 0;
}

Unknown said...

1
2 3
4 5 6
7 8 9 10 in c++

Anonymous said...

1
2 5
3 6 8
4 7 9 10
Can some1 write program for this?

Anonymous said...

enna pa thambi....onnu puriyalaya...????

kapil Indoria said...

int i,j=0,p=1;
for(i=1;i<=10;i++)
{
printf("%d",i);
if(i==p)
{
printf("\n");
p++;
j++;
p=p+j;
}
}

Anonymous said...

int main(){

int i,j,r,k=1;

printf("Enter the range: ");
scanf("%d",&r);

printf("FLOYD'S TRIANGLE\n\n");
for(i=1;i<=r;i++){
for(j=1;j<=i;j++,k++)
{
printf(" %d",k);
printf("\t")

}
printf("\n");
}

return 0;
}

Anonymous said...

0
1 0 1
2 1 0 1 2
3 2 1 0 1 2 3
4 3 2 1 0 1 2 3 4

Anonymous said...

give the c programme for *
* *
* * *
* * * *

Anonymous said...
This comment has been removed by the author.
Anonymous said...

plz someone give me the c program for
1
2 3
4 5 6
7 8 9 10

Anonymous said...

Case1
Read salesperson[10][2],index;
Initialise tsales as 0
Float minimunsales,incentive_amount,avg_sales=0
Loop 0 to n
Read salespersonid and his sales
tsales+=salesperson[index][1]
minimunsales =( avg_sales *2)/(float)3;
Write Salesperson ID Incentive Amount
loop index=0 to 10

if(salesperson[index][1]> minimunsales)

incentive_amount=(float)(salesperson[index][1]- minimunsales)*(float)0.2;
write salesperson[index][0],incentiveamount

End if

Unknown said...

1
2 5
3 6 8
4 7 9 10
Plzzz send this daigram....!

Anil said...

how to print ......

AAAAAAAAAAA
AABBBBBBBAA
ABABBBBBABA
ABBABBBABBA
ABBBABABBBA
ABBBBABBBBA
ABBBABABBBA
ABBABBBABBA
ABABBBBBABA
AABBBBBBBAA
AAAAAAAAAAA

Unknown said...

#include
#include
void main()
{
int i,j,k,n;
clrscr();
printf("\nEnter the Number to increase length= ");
scanf("%d",&n);

for(i=1;i<n;i++)
{
printf("A");
}
printf("\n");
for(i=1;i<n;i++)
{
for(j=1;j<n;j++)
{
if(i==j||i==j*i||j==(n-i)||j==n-1)
{
printf("A");
}
else
{
printf("B");
}

}
printf("\n");
}
for(i=1;i<n;i++)
{
printf("A");
}
getch();
}

Naomeey said...

How about this? Number Tree.

Enter a number: 5
Output:
1
2 3 2
3 4 5 4 3
4 5 6 7 6 5 4
5 6 7 8 9 8 7 6 5

GAUTAM PARMAR said...

1
2 3
4 5 6
7 8 9 10
11 12 13 14 15

Unknown said...

1
121
12321
1234321
Please help me to solve this sequence...

Unknown said...

5 = 1 + 1 + 1 + 1 +1
5 = 1 + 1 + 1 + 2
5 = 1 + 1 + 3
5 = 1 + 4
5 = 2 + 1 + 1 + 1
5 = 2 + 1 + 2
5 = 2 + 3
5 = 3 + 1 + 1
5 = 3 + 2
5 = 4 + 1
how i can do it using looping statement

Unknown said...

*****
*****
*****
*****
*****
*****
*****
*****
*****

Unknown said...

*****
*****
*****
*****
*****
*****
*****
*****
*****
need help.. :(

Learn2All said...

thanks rahul

Deb said...

1
01
101
0101

Unknown said...

1 2 3 4 5
2 3 4 5
3 4 5
4 5
5
help me!

JAGDISH said...

what will be code for this pattern
===>1
==>3 5
=>7 9 11

Unknown said...

1
3 2
4 5 6
10 9 8 7

Unknown said...

please help me with kinda tringle
1
01
101
0101
10101

சிந்துலன் சிந்தைகள் said...

send me the source code for this problem
*
**
***
****
*****

and
*
**
***
****
*****
sinthulanpathman@gmail.com

Unknown said...

ublic class Simple {

public static void main(String[] args) {

int i,j,rem;

for( i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
rem=j%2;
System.out.println(" "+rem);
}
System.out.println();
}

}
}

A shadow my walk said...

if a input the 1 from keyboard output should be A and if i input the 2 output is should be AB
Same ting if 26 inputed output is to be ABCDEF.......Z

Unknown said...

*
**
***
****
*****
****
***
**
*

Unknown said...

how to print

*X*X*
X*X*X
*X*X*
X*X*X
*X*X*

NIMZ said...
This comment has been removed by the author.
NIMZ said...

program for
A
BC
DEF
1 GHIJ

Unknown said...

How to print
23 21 24 19 26 15 28 11 30 7 36

Unknown said...

program for

1 2 3 4 5
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9

help me plz

Unknown said...

1 2 3 4 5
16 17 18 19 6
15 24 25 20 7
14 23 22 21 8
13 12 11 10 9

Unknown said...

01 02 03 04 05
16 17 18 19 06
15 24 25 20 07
14 23 22 21 08
13 12 11 10 09

Unknown said...

1
3 5
7 9 11
13 15 17 19

Unknown said...

please fast reply

Unknown said...

jhvbh

Unknown said...

please reply fastly

*** said...

Hello Friends,
write a program to print the series:
1) 23 21 24 19 26 15 28 11 30 7 36
Logic:
23-2=21
21 3=24
24-5=19
19 7=26
26-11=15
15 13=28
28-17=11
11 19=30
30-23=7
7 29=36
2 3 5 7 11 13 17 19 23 29 31 are prime numbers.

2) 15 29 56 108 208 400
Logic:
2*15-1=29
2*29-2=56
2*56-4=108
2*108-8=208
2*208-16=400

3) 21 32 54 87 131 186
Logic:
21 11*1=32
32 11*2=54
54 11*3=87
87 11*4=131
131 11*5=186
Please Reply your answer...

Unknown said...

guys help,i want this code in c.
1
2*3
4*5*6
4*5*6
2*3
1
if n=3 we have to print this three lines....

Unknown said...

help me for
11 12 13 14 15
7 8 9 10
4 5 6
2 3
1

Unknown said...

1
12
123
1234
12345
1234
123
12
1

Plz share the program for above sequence

Unknown said...

#include
void main()
{
int i,j,k=1,l;
for(i=1;i<=4;i++)
{
l=i;
for (j=1;j<=k ;j++ )
{
if(j>=i+1)
printf("%d",--l);
else
printf("%d",j);
}
k=k+2;
printf(" ");
}
}

Any Problem contact to niteshsrivatva@gmail.com

sds said...

Guys Please Solve..........................
Output:
Enter a Number = 5
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

Bharat said...

how to print this using c
1
2 6
3 7 10
4 8 11 13
5 9 12 14 15

Unknown said...

please someone help me to print this using c:
01
** 03
** ** 06
** ** ** 10
** ** ** ** 15
** ** ** ** ** 21
** ** ** ** ** ** 28
Thanks











Unknown said...

please someone help me to print this using c:
01
** 03
** ** 06
** ** ** 10
** ** ** ** 15
** ** ** ** ** 21
** ** ** ** ** ** 28
Thanks











Unknown said...

I need answer for this question either in C or Java?
7
14 15
28 29 30 31
56 57 58 59 60 61 62 63

Unknown said...
This comment has been removed by the author.
roshni said...

1
6 2
10 7 3
13 11 8 4
15 14 12 9 5

Unknown said...

If 23 is the given input then the output should display as 5. how we should put this program?