Wednesday, November 13, 2013

FOLLOWING FORMAT

/* WAP TO PRINT THE FOLLOWING FORMAT  :-
   *
 *   *
*   *   *
     *   *   *   *
   *   *   *   *   *           



#include<stdio.h>
#include<conio.h>
 void main()
 {
int i,j;
int row,space;

clrscr();

printf("Enter the no. of rows you want= ");
scanf("%d",&row);
clrscr();
space=row-1;
for(i=1;i<=row;i++)
{
for(j=1;j<=space;j++)
{
printf("  ");                     // 2-SPACES.
}
for(j=1;j<=i;j++)
{
printf("*   ");                   // 1 * & 3-SPACES.
}
printf("\n");
space=space-1;
}
getch();
 }

FOLLOWING FORMAT

/* WAP TO PRINT THE FOLLOWING FORMAT  :-
   *
 *   *
*   *   *
     *   *   *   *
   *   *   *   *   *           



#include<stdio.h>
#include<conio.h>
 void main()
 {
int i,j;
int row,space;

clrscr();

printf("Enter the no. of rows you want= ");
scanf("%d",&row);
clrscr();
space=row-1;
for(i=1;i<=row;i++)
{
for(j=1;j<=space;j++)
{
printf("  ");                     // 2-SPACES.
}
for(j=1;j<=i;j++)
{
printf("*   ");                   // 1 * & 3-SPACES.
}
printf("\n");
space=space-1;
}
getch();
 }

/*WAP TO PRINT THE FOLLOWING FORMAT:
      *
      # #
      * * *
      # # # #
      * * * * *      


#include<stdio.h>
#include<conio.h>
 void main()
 {
int i;
int j;

clrscr();

for(i=1;i<=5;i++)
{
for(j=1;j<=i;j++)
{
if(i%2!=0)
printf(" *");
else
printf(" #");
}
printf("\n");
}
getch();
 }












#include<stdio.h>
#include<conio.h>
 void main()
 {
int i,j;
int row,space;

clrscr();

printf("Enter the no. of rows you want= ");
scanf("%d",&row);
clrscr();
space=row-1;
for(i=1;i<=row;i++)
{
for(j=1;j<=space;j++)
{
printf("  ");
}
for(j=1;j<=i;j++)
{
printf("* ");
}
printf("\n");
space=space-1;
}
getch();
 }