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.

Sunday 23 June 2013

Program to print the Star pattern 3

#include<stdio.h>
main()
{
char prnt = '*';
int i, j, k, s, nos = -1;
clrscr();
for (i = 5; i >= 1; i--)
{
for (j = 1; j <= i; j++)

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

nos = nos + 2; 
printf("\n");
}
nos = 5;
for (i = 2; i <= 5; i++)

for (j = 1; j <= i; j++)

printf("%2c", prnt);
}
for (s = nos; s >= 1; s--)
{  
printf("  "); 

for (k = 1; k <= i; k++)
{  
if (i == 5 && k == 5)
{   
break;  
}  
printf("%2c", prnt); 

nos = nos - 2; 
printf("\n");
}
getch();
}


No comments:

Post a Comment