Friday, November 21, 2014

C print pyramid pro



C Program to Print Pyramid of Multiplication Tables

#include
#include
int main()
 {
    int i, j;
     for (i = 0; i <= 6; i++)
 {
        for (j = 0; j <= i; j++)
   {
            printf("%d\t", i * j);
        }
        printf("\n");
    }
    return(0);
}

Output
0
0       1
0       2       4
0       3       6       9
0       4       8       12      16
0       5       10      15      20      25
0       6       12      18      24      30      36

C Program to Print 1-10 Numbers in Pyramid fashion

 #include
#include 
int main()
 {
   int i, j;
   int count = 1;

   for (i = 0; i <= 4; i++)
    {
      printf("\n");
      for (j = 0; j < i; j++)
    {
         printf("%d\t", count);
         count++;
      }
   }
   return(0);
}

Output
1
2       3
4       5       6
7       8       9       10

C Program to Print Inverted Pyramid

 #include
#include 
int main()
 {
   int i, j;
   char ch = '*';

   for (i = 4; i >= 0; i--)
 {
      printf("\n");
      for (j = 0; j < i; j++)
         printf("%c", ch);
   }
   return(0);
}

C Program to Print Binary Numbers Pyramid Pattern

 #include
#include
 int main()
{
   int i, j;
   int count = 1;

   for (i = 1; i <= 4; i++)
    {
      printf("\n");
      for (j = 1; j <= i; j++)
    {
         printf("%d", count % 2);
         count++;
      }
       if (i % 2 == 0)
         count = 1;
      else
         count = 0;
   }
   return(0);
}

C Program to Print Number Pyramid in C Programming

#include
#include
int main()
{
int i,j;
int num;
printf("enter the number of digits: ");
scanf("%d",&num);
for(i=0;i<=num;i++)
{
for(j=0;j
{
printf("%d",i);
}
printf("\n");
}
return(0);
}

Output

Enter the number of digits : 5
1
2        2
3        3        3
4        4        4
5        5        5        5        5

No comments:

Post a Comment