samedi 9 juillet 2022

how to solve this pattern using for loop and if conditions in c language [closed]

*
* * * *
*
*
* * * * * * * *
*
* * * * * * * * * *
*
*

I got answer to first pattern but I could not find code for second pattern I don't know how to multiply by 2, add by 2 in printing after the first pattern and repeat it

can you please help me to solve,I am confused here

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
int num,i,j,k;
printf("Enter the number of rows :");
scanf("%d",&num);
for(i=1;i<=num;i++)
{
for(j=1;j<=2;j++)
{
for(k=1;k<=j;k++)
{
printf("*  ");
printf("\n");
}
printf("\n");
}

}
return EXIT_SUCCESS;
}

Aucun commentaire:

Enregistrer un commentaire