Computer Science, asked by honey66238, 1 year ago

7) Write a menu driven program to print the pattern l and pattern 2
1
21 321 4321 ...... n terms​

Answers

Answered by bhuwanpaneru
1

Answer:

Pattern 1 pattern 2

1 1

21 21

321 321

4321 4321

54321 54321

Explanation:

pattern 1

#include <stdio.h>

int main()

{

int i, j, N;

printf("Enter N: ");

scanf("%d", &N);

for(i=1; i<=N; i++)

{

// Logic to print numbers

for(j=i; j>=1; j--)

{

printf("%d", j);

}

printf("\n");

}

return 0;

}

pattern 2

#include <stdio.h>

int main()

{

int i, j, N;

printf("Enter N: ");

scanf("%d", &N);

for(i=1; i<=N; i++)

{

// Logic to print spaces

for(j=1; j<=N-i; j++)

{

printf(" ");

}

// Logic to print numbers

for(j=i; j>=1; j--)

{

printf("%d", j);

}

printf("\n");

}

return 0;

}

Similar questions