180k views
0 votes
Write a program to generate the given pattern. CCCCCC CCSSCC SSSSSS SSSSSS KKSSKK KKKKKK

User Lukyer
by
8.5k points

2 Answers

3 votes

Final answer:

A Python program was provided to generate a character pattern consisting of 'C', 'S', and 'K'. The program uses a list to store the pattern lines and prints them to display the desired output.

Step-by-step explanation:

You have asked to write a program to generate a pattern that consists of characters C, S, and K in a specified arrangement. Here is a simple example in Python that accomplishes this task:

pattern = [
'CCCCCC',
'CCSSCC',
'SSSSSS',
'SSSSSS',
'KKSSKK',
'KKKKKK']

for line in pattern:
print(line)

This program uses a list to hold the patterns for each line of the desired output. It then iterates through the list and prints each line to display the entire pattern.

User Rameshthoomu
by
8.1k points
6 votes

Answer:

#include <stdio.h>

int main()

{

int i, j;

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

{

for(j=1; j<=6; j++)

{

if(i==1 || i==6)

{

printf("C");

}

else if(i==2 || i==5)

j==6)

printf("K");

else

printf("S");

else

{

printf("S");

}

}

printf("\\");

}

return 0;

}

User Mullefa
by
8.2k points

Related questions

asked Mar 14, 2023 48.4k views
Piotr Mirosz asked Mar 14, 2023
by Piotr Mirosz
8.1k points
1 answer
16 votes
48.4k views
asked Oct 23, 2022 162k views
Dewayne asked Oct 23, 2022
by Dewayne
8.3k points
1 answer
2 votes
162k views