Saturday, October 5, 2013

Flag Structure Design

Q. Write a C program to print the following flag design as:

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

Ans.

/*c program for flag design*/
#include<stdio.h>
int main()
{

 int num=7,r,c;
 for(c=1; c<=9; c++)
    printf(" *");
 printf("\n");
 for(r=1; r<=num; r++)
 {
  if(r==4)
  {
    for(c=1; c<=2; c++)
       printf(" *");
  }
  else
  {
    for(c=1; c<=4; c++)
       printf(" *");
  }
  printf("\n");
 }
 for(c=1; c<=9; c++)
    printf(" *");
 getch();
 return 0;
}

/**************************************************************
The output of above program would be:
***************************************************************/


Output of Flag Structure Design C program
Figure: Screen shot for flag-structure-design C program