jeudi 8 juin 2023

Pattern using loop for skip count (f pattern)

Does not get the logic behind the Given Question..and some one help to get me the logic .

Write a program to skip two elements after the occurrence of an odd number and print the array elements in the following pattern

* *
*
*
*
* * * *
*
*
*
*
*
*
* * * * * *
#include<stdio.h>
int main()
{
    int n,i,j,k;
    printf("enter the ");
    scanf("%d",&n);
    for(i=1; i<=n; i++) {
        for(j=1; j<=3; j++) {
            printf("*\n");
        }
        for(k=1; k<=i; k++) {
            printf("* * *\n");
        }
    }
    return 0;
}

is this something like it.it is the code of another like project.Is it like this or any other logic. please tell me.

Aucun commentaire:

Enregistrer un commentaire