This discussion is now closed.
x=6;
for (n=x; n>0; n--)
{
for (i=n; i>0; i--)
{
printf("%s","* ");
}
prinf("%s\n","");
}
x=6;
for (n=x; n>0; n--)
{
for (i=n; i>0; i--)
{
printf("%s","* ");
}
prinf("%s\n","");
}
printf("*");
or printf("\n");
would suffice.x=6;
/* this part is just the reverse of your first question
except for the very last line (of 6 *'s) */
for (n=1; n<x; n++)
{
for (j=n; i>0; i--)
{
printf("%s","* ");
}
printf("%s\n","");
}
/* this part is exactly the same as your first question */
for (n=x; n>0; n--)
{
for (i=n; i>0; i--)
{
printf("%s","* ");
}
printf("%s\n","");
}
#include <stdio.h>
/* The height of the rhombus, should be an odd number to look correct */
#define HEIGHT 11
int main(int argc, char** argv)
{
int l_pos; /* The current position of the left side of thr rhombus*/
int r_pos; /* The current position of the right side of the rhombus */
int i;
/* Start at the centre of the rhombus */
l_pos = r_pos = (HEIGHT / 2);
for(i = 0; i < HEIGHT; i++)
{
int j;
for(j = 0; j < r_pos; j++) /* Iterate till we get to the right hand side */
{
if(j == l_pos && l_pos != r_pos) /* If we're at the left side, print a '*' */
{
printf("*");
}
else /* Otherwise print a space for padding */
{
printf(" ");
}
}
printf("*\n"); /* Now at the right hand side, so print a '*' and move to next line */
if(i < (HEIGHT / 2)) /* Once we get to half-way down the rhombus, the sides should start closing in */
{
l_pos--;
r_pos++;
}
else
{
l_pos++;
r_pos--;
}
}
}
#include <stdio.h>
/* The height of the shape */
#define HEIGHT 17
/* The width of the shape */
#define WIDTH (HEIGHT / 2)
int main(int argc, char** argv)
{
int i;
int pos = WIDTH; /* The '*' chars should start at the right side */
for(i = 0; i < HEIGHT; i++)
{
int j;
for(j = 0; j < WIDTH; j++)
{
if(j < pos) /* If we're before pos, print a padding space */
{
printf(" ");
}
else /* Else we've reached the start of the '*' chars */
{
printf("*");
}
}
printf("\n");
if(i < (HEIGHT / 2)) /* If we're less than half-way down the shape expand leftwards */
{
pos--;
}
else
{
pos++;
}
}
}
Last reply 2 days ago
Is MathsFM French Alevels good for a CS degree at top uni (OX, UCL, Durham etc)Last reply 3 days ago
OCR A-level Computer Science Paper 1 (H446/01) - 12th June 2023 [Exam Chat]Last reply 2 weeks ago
OCR A-level Computer Science Paper 2 (H446/02) - 19th June 2023 [Exam Chat]Last reply 3 weeks ago
AQA A-level Computer Science Paper 1 (7517 1A - 1E) - 12th June 2023 [Exam Chat]Last reply 1 month ago
Not receiving any response from University of Birmingham.Last reply 3 months ago
OCR GCSE Computer Science Paper 1 (J277/01) - 19th May 2023 [Exam Chat]Last reply 3 months ago
AQA GCSE Computer Science Paper 2 (8525/2) - 25th May 2023 [Exam Chat]Last reply 2 days ago
Is MathsFM French Alevels good for a CS degree at top uni (OX, UCL, Durham etc)Last reply 3 days ago
OCR A-level Computer Science Paper 1 (H446/01) - 12th June 2023 [Exam Chat]Last reply 2 weeks ago
OCR A-level Computer Science Paper 2 (H446/02) - 19th June 2023 [Exam Chat]Last reply 3 weeks ago
AQA A-level Computer Science Paper 1 (7517 1A - 1E) - 12th June 2023 [Exam Chat]Last reply 1 month ago
Not receiving any response from University of Birmingham.Last reply 3 months ago
OCR GCSE Computer Science Paper 1 (J277/01) - 19th May 2023 [Exam Chat]Last reply 3 months ago
AQA GCSE Computer Science Paper 2 (8525/2) - 25th May 2023 [Exam Chat]