Code:
* *
* *
*
* *
* *
|
Newbie Member
|
|
| 9Mar2012,23:29 | #1 |
|
How to print the following pattern in c???please give me the codes
Code:
* *
* *
*
* *
* *
|
|
Newbie Member
|
|
| 9Mar2012,23:32 | #2 |
|
* *
* * * * * * * how to print this pattern?? |
|
Go4Expert Member
|
|
| 10Mar2012,13:59 | #3 |
|
Code:
/*
* *
* *
*
* *
* *
*/
#include <stdio.h>
void displayStar()
{
int starCount = 0;
bool invalid = true;
while(invalid)
{
printf("Enter odd number of start you wants in row/column -> ");
scanf("%d", &starCount);
if((starCount % 2 == 0) || (starCount > 100) || (starCount <= 0) ) {
printf("Please Enter any ODD number in range of 3 to 100\n");
invalid = true;
fflush(stdin);
}
else{
invalid = false;
}
}
int innerCount = 0;
int outerCount = 0;
for(outerCount = 0; outerCount < starCount; outerCount++)
{
for(innerCount = 0; innerCount < starCount; innerCount++)
{
if((innerCount == outerCount) ||
(innerCount == starCount - outerCount -1))
{
printf("*");
}
else
{
printf(" ");
}
}
printf("\n");
}
}
int main(int argc, char* argv[])
{
displayStar();
return 0;
}
shabbir
like this
|
|
Go4Expert Member
|
|
| 10Mar2012,14:01 | #4 |
|
Code:
/*
* *
* *
*
* *
* *
*/
#include <stdio.h>
void displayStar()
{
int starCount = 0;
bool invalid = true;
while(invalid)
{
printf("Enter odd number of start you wants in row/column -> ");
scanf("%d", &starCount);
if((starCount % 2 == 0) || (starCount > 100) || (starCount <= 0) ) {
printf("Please Enter any ODD number in range of 3 to 100\n");
invalid = true;
fflush(stdin);
}
else{
invalid = false;
}
}
int innerCount = 0;
int outerCount = 0;
for(outerCount = 0; outerCount < starCount; outerCount++)
{
for(innerCount = 0; innerCount < starCount; innerCount++)
{
if((innerCount == outerCount) ||
(innerCount == starCount - outerCount -1))
{
printf(" * ");
}
else
{
printf("");
}
}
printf("\n");
}
}
int main(int argc, char* argv[])
{
displayStar();
return 0;
}
|