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

User Lukyer
by
7.7k 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
7.3k 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
7.2k points