Sunday, July 14, 2013

write a program to print following number pattern ?

1 2 3 4
  2 3 4
     3 4
        4
Program:
#include<stdio.h>
#include<conio.h>

void main()
{
   int r, p, k,g=0,h=1;
   clrscr();
   printf("\n enter the no of row");
   scanf("%d", &r);
   for ( k = r ; k >= 1 ; k-- )
   {
       for ( p = 1 ; p <= g; p++ )
       printf(" ");
       g++;
       for ( p = h;p <=r ; p++)
       printf("%d", p);
       h++;

       printf("\n");
   }

   getch();
}
 
Output:
image
{ Read More }


Saturday, July 13, 2013

write a program to print following number pattern ?

4 3 2 1
  3 2 1
    2 1
      1
Program:
#include<stdio.h>
#include<conio.h>

void main()
{
   int r, p, k,g=0;
   clrscr();
   printf("\n enter the no of row");
   scanf("%d", &r);
   for ( k = r ; k >= 1 ; k-- )
   {
       for ( p = 1 ; p <= g; p++ )
       printf(" ");
       g++;
       for ( p = r;p >0 ; p --)
       printf("%d", p);
       r--;

       printf("\n");
   }
   getch();
}

Output:
image
{ Read More }


write a program to print following number pattern ?

     1
    12
  123
 1234
12345
Program:
#include<stdio.h>
#include<conio.h>

void main()
{
   int r, p, k,g=0,h=1;
   clrscr();
   printf("\n enter the no of row");
   scanf("%d", &r);
   for ( k = r ; k >= 1 ; k-- )
   {
       for ( p = --r; p >0; p--)
       printf(" ");

       for ( p = 1;p <=h ; p++)
       printf("%d", p);
       h++;

       printf("\n");
   }
   getch();
}

Output:
image

{ Read More }


write a program to print following number pattern ?

1
23
456
78910
Program:
#include<stdio.h>
#include<conio.h>

void main()
{
   int r, p, k,h=1;
   clrscr();
   printf("\n enter the no of row");
   scanf("%d", &r);
   for ( k = 1 ; k <= 5 ; k++ )
   {
       for ( p =1; p <=k; p++,h++)
       printf("%d", h);

       printf("\n");
   }

   getch();
}

Output:
image


{ Read More }


Thursday, July 11, 2013

write a program to print the following ‘*’ pattern ?

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

Program:
#include<stdio.h>
#include<conio.h>

void main()
{
  int n,r,a,p;
  clrscr();
  printf(" enter the no of rows  ");
  scanf("%d",&n);
  for(r=1;r<=n; r++)
  {
   for(p=r; p>=1; p--)
    printf(" ");
   for(a=1; a<=n-r;a++)
    printf("*");
   for(a=n-r-1; a>=1; a--)
    printf("*");
   printf("\n");
  }
  getch();
}

Output:
image

{ Read More }