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;
}
/**************************************************************
* * * * * * * * *
* * * *
* * * *
* * * *
* *
* * * *
* * * *
* * * *
* * * * * * * * *
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:
***************************************************************/Figure: Screen shot for flag-structure-design C program |
No comments:
Post a Comment