vendredi 9 octobre 2020

How to print diagonal star pattern in C

I'm confused to print this type of pattern given below:

 *   *
  * * 
   *  
  * * 
 *   * 

I've tried this:

#include <stdio.h>

int main()
{
    int n; 
    printf("Enter the value of base\n>>> ");
    scanf("%d", &n);

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j + n; j++)
        {
            if (// ??? )
            {
                printf("*");
            }
            
            else
            {
                printf(" ");
            }
            
        }

        printf("\n");
    }

    return 0;
}

but I don't know what is the condition of if statement Help Me to solve this please

Aucun commentaire:

Enregistrer un commentaire