This blog consists of C and C++ programs. C and C++ programming is the basics to learn any programming language. Most of the programs are provided with their respective outputs. This blog also contains Data Structures programs using Object-Oriented Programming (C++). Some of the best books for learning C and C++ programming are also mentioned.

Saturday 22 June 2013

Program to print the Star pattern 2

#include<stdio.h>
main()
{
char prnt = '*';
int i, j, k, s, c = 1, nos = 9;
clrscr();
for (i = 1; c <= 4; i++)
{
if ((i % 2) != 0)
{
for (j = 1; j <= i; j++)

printf("%2c", prnt);
}
for (s = nos; s >= 1; s--)
{
if (c == 4 && s == 1)
{
break;
}
printf("  ");
}
for (k = 1; k <= i; k++)
{
if (c == 4 && k == 5)
{
break;
}
printf("%2c", prnt);
}
printf("\n");
nos = nos - 4;
++c;
}
}
getch();
}


No comments:

Post a Comment