Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

C Exercise 6

C Exercise 6

100 Classic C Language Examples 100 Classic C Language Examples

**Problem:** Use * characters to print the pattern of the letter C.

**Program Analysis:** You can first write the letter C on paper using '*' characters, then output it line by line.

Program source code:

Example

// Created by www.runoob.com on 15/11/9.

// Copyright (c) 2015 Runoob Tutorial. All rights reserved.

//

#include

"

stdio.h

"

int

main

(

)

{

printf

(

"

Print the letter C with * characters!

\

n

"

)

;

printf

(

"


\

n

"

)

;

printf

(

"

\

n

"

)

;

printf

(

"

\

n

"

)

;

printf

(

"


\

n

"

)

;

}

The output of the above example is:



用 * 号输出字母 C!

 ****

 *

 * 

 ****

Example

#include

int

main

(

)

{

   

// Define the character pattern

   

const

char

c_pattern

[

]

=

{

       

" ****"

,

       

" *"

,

       

" *"

,

       

" ****"

   

}

;

   

// Output the character pattern

   

printf

(

"Print the letter C with * characters!\n"

)

;

   

for

(

int

i

=

0

;

i

<

sizeof

(

c_pattern

)

/

sizeof

(

c_pattern

[

0

]

)

;

i

++

)

{

       

printf

(

"%s\n"

,

c_pattern

[

i

]

)

;

   

}

   

return

0

;

}

100 Classic C Language Examples 100 Classic C Language Examples