C Exercise Example 6
Title:Output the pattern of the letter C using asterisks.
Program analysis:You can first use the '*' symbol to write the letter C on paper, then output it line by line.
Program source code:
Example
// Created by www.example.com on 15/11/9.
// Copyright © 2015 Example. All rights reserved.
//
#include "stdio.h"
int main()
{
printf("Output letter C with *!\n");
printf(" ****\n");
printf(" *\n");
printf(" * \n");
printf(" ****\n");
}
The output result of the above example is:
用 * 号输出字母 C! **** * * ****
Example
#include <stdio.h>
int main() {
// Define character graphic
const char *c_pattern[] = {
" ****",
" *",
" *",
" ****"
};
// Output character graphic
printf("Use * to output the letter C!\n");
for (int i = 0; i < sizeof(c_pattern) / sizeof(c_pattern[0]); i++) {
printf("%s\n", c_pattern[i]);
}
return 0;
}
int main() {
// Define character graphic
const char *c_pattern[] = {
" ****",
" *",
" *",
" ****"
};
// Output character graphic
printf("Use * to output the letter C!\n");
for (int i = 0; i < sizeof(c_pattern) / sizeof(c_pattern[0]); i++) {
printf("%s\n", c_pattern[i]);
}
return 0;
}