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.

33 comments:

  1. Replies
    1. enna pa thambi....onnu puriyalaya...????

      Delete
  2. 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

    ReplyDelete
    Replies
    1. 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

      Delete
  3. 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

    ReplyDelete
  4. wot i do to make my programming strong

    ReplyDelete
  5. thanku very much

    ReplyDelete
  6. * *
    ** **
    *** ***
    *******


    pls send the diagram coding

    ReplyDelete
  7. hai,i want this code,could you send me

    ReplyDelete
  8. can you send me this program?

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

    ReplyDelete
  10. what happens if return 0 is not there

    ReplyDelete
  11. ABCDCBA
    ABC CBA
    AB BA
    A A

    please help me to solve this sequence

    ReplyDelete
  12. how to print
    54321
    5432
    543
    54
    5

    ReplyDelete
    Replies
    1. #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;
      }

      Delete
  13. how to print
    55555
    4444
    333
    22
    1

    ReplyDelete
    Replies
    1. #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;
      }

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

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

    ReplyDelete
    Replies
    1. 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;
      }
      }

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

    ReplyDelete
  17. 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;
    }

    ReplyDelete
  18. 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

    ReplyDelete
  19. give the c programme for *
    * *
    * * *
    * * * *

    ReplyDelete
  20. This comment has been removed by the author.

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

    ReplyDelete
  22. 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

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

    ReplyDelete
  24. how to print ......

    AAAAAAAAAAA
    AABBBBBBBAA
    ABABBBBBABA
    ABBABBBABBA
    ABBBABABBBA
    ABBBBABBBBA
    ABBBABABBBA
    ABBABBBABBA
    ABABBBBBABA
    AABBBBBBBAA
    AAAAAAAAAAA

    ReplyDelete
    Replies
    1. #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();
      }

      Delete
  25. 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

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

    ReplyDelete