+ 9
moon exercise
34 odpowiedzi
+ 10
You're not using a condition after 'if'in line 20.
+ 7
Adriana Garcia in your code
//you have error in this code, which i soecified 8n comments ,read it and make correct
else {
printf (" ");
if { //incomplete statement
for (i=0;n; n){ //loop has no exit condition
for (j=i;j=n-1; j--) //wr9ng condition here
printf ("*");
}
}
}
else { //this is wrong brace match for if statement
printf (""); //empty pr8nt statement,why this ?
}
}
+ 6
The requirements are a little short on detail. What phase - Full Moon, Half, Crescent? How big? Here is a small Full Moon:
puts("*");
The easiest solution is to draw a New Moon:
puts("");
Does it necessarily need to be generated by algorithm, or may it be a simple set of manually-constructed strings?
+ 4
What's your doubt or problem? What are you trying..?
+ 4
#include <stdio.h>
int main() {
int n, x=0;
printf ("Size of the moon?\n ");
scanf ("%d", &n);
if (n<= 5)
printf ("no moon");
else {
/* Just try it first like in loop
from i=0 to n
For j=i to 0 and for j=n-I reoeat printing * I times, else print space
Increment I, decrement n
*/
if(n%2!=0) n++;
//this is because if odd numbers it may lead wrong,
//so that why here adding 1 so it becomes even
for (int i=0; i<n/2-1; i++)
{
for(int j=0; j<=n; j++)
{
if((j>=x && j<=i+x ) || (j>=n-x && j<=n+x))
printf(" *");
else
printf(" ");
}
x++; //this is for in next we add only x stars at begin and end
printf("\n");
}
}
return 0;
}
+ 3
Show the how it look like..? For graphic content, here it not support. You can try a simple patterns..
+ 3
It is not possible here (without graphics) to print a exact round. But you can try to print '0'. Zero or a half moon..
Is that what you need? If I find what you trying then I can try to suggest..!
+ 3
* *
* * * *
* * *
Is this OK.?
+ 3
OK. First find required output..
The console is a rectangular matrix type plot so without graphic you can only get only similar but rectangular type output.. And above that is like a big curve inside a small curve ((.
(the crescent's upper and lower, but can't fill between) ((. the half moon is easy one..
+ 3
okeyy
+ 3
Just try it first like in loop
from i=0 to n
For j=i to 0 and for j=n-I reoeat printing * I times, else print space
Increment I, decrement n
+ 3
Adriana Garcia you can't just write stuff and expect a moon to appear. You need to tell to the machine exactly what to do, and if you miss a single semicolon the program wouldn't work.
It seems you are having troubles using loops. You are a human, I know you can do it: Google "for loop c" and read informations until you know all you need to know.
Then make a serious attempt and if you are still having troubles and can't figure out why your program doesn't act as you wish, we will be glad to help you.
+ 3
Rewrite with while loop... 🤔
+ 2
yo draw the moon
+ 2
but dont know how
+ 2
i do not know how to draw the moon
+ 2
any ideas
+ 2
I know it is with for but i do not know how to write it
+ 2
it has to be crescent, still not half moon
+ 2
the size depende on the answer of the question the person types on the computer