Help me in solving LPYAS164 problem

My issue

i want this answer

My code

#include <stdio.h>

void printWavePattern(int N) {
    // Loop through each row
    for (int row = 1; row <= N; row++) {
        for (int col = 1; col <= N; col++) {
            // Print `*` if the conditions for the wave pattern are met
            if (col % 2 == 1) {
                // For odd columns: stars in every row
                printf("* ");
            } else {
                // For even columns: star only at the top and bottom of the column
                if (row == 1 || row == N) {
                    printf("* ");
                } else {
                    printf("  "); // Empty space for middle rows in even columns
                }
            }
        }
        printf("\n"); // Newline for the next row
    }
}

int main() {
    int N;
    printf("Enter the value of N: ");
    scanf("%d", &N);

    printWavePattern(N);

    return 0;
}

Learning course: Roadmap to 3*
Problem Link: https://www.codechef.com/learn/course/klu-roadmap-3star/KLURMP300B/problems/LPYAS164