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.

69 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
  27. 1
    121
    12321
    1234321
    Please help me to solve this sequence...

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

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

    ReplyDelete
  29. *****
    *****
    *****
    *****
    *****
    *****
    *****
    *****
    *****

    ReplyDelete
    Replies
    1. *****
      *****
      *****
      *****
      *****
      *****
      *****
      *****
      *****
      need help.. :(

      Delete
  30. Replies
    1. 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();
      }

      }
      }

      Delete
  31. 1 2 3 4 5
    2 3 4 5
    3 4 5
    4 5
    5
    help me!

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

    ReplyDelete
  33. please help me with kinda tringle
    1
    01
    101
    0101
    10101

    ReplyDelete
  34. send me the source code for this problem
    *
    **
    ***
    ****
    *****

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

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

    ReplyDelete
  36. how to print

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

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

    ReplyDelete
  38. program for
    A
    BC
    DEF
    1 GHIJ

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

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

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

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

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

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

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

    ReplyDelete
  46. 1
    12
    123
    1234
    12345
    1234
    123
    12
    1

    Plz share the program for above sequence

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

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

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











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











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

    ReplyDelete