Share Info With Your Friends

       
   

c program to print Floyd's triangle

C program to print Floyd's triangle:- This program prints Floyd's triangle. Number of rows of Floyd's triangle to print is entered by the user. First four rows of Floyd's triangle are as follows :-
1
2 3
4 5 6
7 8 9 10
It's clear that in Floyd's triangle nth row contains n numbers.
C programming code
#include<stdio.h>
#include<conio.h>
main()
{
   int n, i,  c, a = 1;
   printf("Enter the number of rows of Floyd's triangle to print\n");
   scanf("%d",&n);
   for ( i = 1 ; i <= n ; i++ )
   {
      for ( c = 1 ; c <= i ; c++ )
      {
         printf("%d ",a);
         a++;
      }
      printf("\n");
   }
   getch();
   return 0;
}

Output of program:

please give me coding of following o/p -
EDCBA
 DCBA
  CBA
   BA
    A

character pattern c code 

#include<stdio.h>

main()
{
   int n, c, k, space = 0;
   char ch, temp;

   scanf("%d", &n);

   ch = 'A'+n-1;
   temp = ch;

   for ( k = n ; k >= 1 ; k-- )
   {
      for ( c = 1 ; c <= space; c++)
         printf(" ");

      space++;

      for ( c = 1 ; c <= k ; c++ )
      {
         printf("%c",temp);
         temp--;
      }

      printf("\n");
      ch--;
      temp = ch; 
   }

   return 0;
}

A
B B
C C C
D D D D
E E E E E
and so on.

source code 

This code prints the above pattern of characters.
#include<stdio.h>

main()
{
    int c, n, k;
    char ch = 'A';


    printf("Enter number of rows\n");
    scanf("%d",&n);

    for ( c = 1 ; c <= n ; c++ )
    {
        for ( k = 1 ; k <= c ; k++)
            printf("%c ", ch);

        printf("\n");
        ch++;
    }

    return 0;
}

Previous
Next Post »

Thanks for your feed back we will soon reply you EmoticonEmoticon

:)
:(
=(
^_^
:D
=D
=)D
|o|
@@,
;)
:-bd
:-d
:p
:ng