HI i made this program for odd inputs if press 5 then
*****
* *
*****
* *
*****

but not showing the correct answer.
write a right code if u can plz thanks alott.

#include <stdio.h>

int main()
{
        int num, i;
        printf("press any odd num");
        scanf("%d", &num);
        if (num % 2 == 0)
                printf("use odd number thanks");
        else 
        {
           
            for (i = 1; i <= num; i++)
            {
                
                if (i % 2 == 1) // If position is odd
                {
  
                        for (int i = 1; i <= num; i++)
                                printf("*");
                        printf("\n"); // Print a newline for good looking output
                }
                else 
                {
                     
                     printf("*");

                     for (int i = 2; i <= num - 1; 
                          printf(" ");
                     printf("*\n"); 
                }
           }
      }

     return 0;
}

Recommended Answers

All 5 Replies

Stop creating new threads for the same problem. I'm getting sick of cleaning up this mess after you :icon_frown:

And perhaps you should elaborate on what you mean by "not showing the correct answer", we're not clairvoyant, you know?

Stop creating new threads for the same problem. I'm getting sick of cleaning up this mess after you :icon_frown:

And perhaps you should elaborate on what you mean by "not showing the correct answer", we're not clairvoyant, you know?

man this is forum i need this program and i am doing practise i do this y u cant show ur effort a little here plz????? i needa solution i do till that but not showing me answer.

commented: Whatever. -2
commented: BZZZZT. Sorry, thanks for playing. -1

You should start by reading the rules of this forum. Which will tell you:

Do not flood the forum by posting the same question more than once (ie in multiple forums).

Also one to keep in mind:

We strive to be a community geared towards the professional. We strongly encourage all posts to be in full-sentence English. Please do not use "leet" speak or "chatroom" speak.

y u cant show ur effort a little here plz?????

how about YOU show a little effort, and keep your mess in one thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.