Although C language is the first choice for many beginners entering the programming world, very few actually make a career out of it, with even less than half of those who merely “look at C and stop”!
● Many languages like C++, Java, Object-C, etc., have syntactic features similar to C language, learning C language can provide a solid foundation for programming design.
● As a historically significant programming language, C language has an unparalleled wide range of application fields, from “Hello World!” to operating systems, C language is everywhere in the workplace. Mastering C language will be greatly beneficial.
● The problem analysis method emphasized by C language, which is oriented towards processes, is the best way to cultivate our flexibility and rigor in thinking.
Common “Pits”
Which compiler is better?
GCC or Visual C++?
Which IDE is better?
Visual Studio or Vim or emacs?
What is the result of this expression?
Could it be this?
If there is a problem that is not understood, what should I do?
Should I look for help online?
Learning Sequence for C Language
(1) Choose a good introductory book and study systematically.
(2) Get hands-on practice and exercises, as any theoretical knowledge needs practical verification.
(3) Correctly recognize and understand C language, grasp the key points of learning, and avoid scattering your attention.
1) Read More Books
Do not just memorize those terms and rules; the focus of programming languages lies in application. Summarize and reflect during application, define those terms in your own words, and summarize those syntactic rules and meanings in your own language. Yes, do not think “what you feel”, but understand “what you feel” through learning, ultimately reaching “what you think”!
2) Operations and Practice
C language is a tool, and we need to familiarize ourselves with the tool’s performance, usage methods, and techniques through continuous operation and practice; merely staying at the level of theoretical discussion is far from enough.
Although C language is a high-level programming language, it still involves many underlying aspects of computer systems, such as pointers. Understanding more about computer principles will help broaden your knowledge base.
4)Practice More
Do not just stay at coding; the focus of programming design lies in design. When doing exercises, pick up a pen and paper to organize your thoughts and record your analysis and problem-solving ideas. After a while, revisit your previous thoughts and evaluate them, meaning that learning C language requires repeated engagement in learning.
5)Repetitive Learning
Learning C language requires repeated engagement in learning. Periodically organize what you have learned and your previous thoughts,
First time, focus on understanding basic syntax and knowledge points
Second time, experience basic syntax and knowledge points through practice
Third time, practice systematically and exercise design thinking
Scroll down to view exercises and answers
1) Assume the beginning of a program is as follows.
#define BOOK “War and Peace”
int main(void){
float coast =12.99;
float percent = 80.0;
Construct a printf() statement using BOOK, coast, and percent to print the following content.
This copy of “War and Peace” sells for $12.99.
That is 80% of list.
Analysis and Answer:
The program requires printing a string with double quotes, so the printf() function needs to include the escape sequence “. Moreover, 80% needs to use the floating-point data percent, and the printout requires adding a modifier, while the percent symbol must be printed using the conversion specifier %%. The specific code is as follows.
*/
#include
#define BOOK “War and Peace”
int main(void){
float coast =12.99;
}
float percent = 80.0;
printf(“This copy of \”%s\” sells for $%.2f.\n”,BOOK,coast);
printf(“That is %.0f%% of list.\n”,percent);
return 0;
2) What conversion specifier should be used to print the following items?
a. A decimal integer with field width equal to its digit count;
b. A hexadecimal integer like 8A, with a field width of 4;
c. A floating-point number like 232.346, with a field width of 10;
d. A floating-point number like 2.33e+002, with a field width of 12;
e. The first 8 characters of a string with a field width of 30.
Analysis and Answer:
a. The conversion specifier for integer data is %d; since the field width is equal to its digit count, no special modifier is needed, so the conversion specifier is %d;
b. The conversion specifier for hexadecimal data (output uppercase characters should use uppercase X) is %X; since the width is 4, using 4 as a modifier, the conversion specifier is %4X;
c. The conversion specifier for floating-point data is %f; for a field width of 10 with 3 decimal places, it should be expressed as 10.3, so the conversion specifier is %10.3f;
d. The conversion specifier for displaying exponent is %e; field width is 12 with 2 decimal places, it should be expressed as 12.2, so the conversion specifier is %12.2e;
e. The conversion specifier for string is %s; with a length of 30, left-aligned, using the modifier -30, the conversion specifier is %-30s;
3) What conversion specifier should be used to print the following items?
a. An unsigned long integer with a field width of 15;
b. A hexadecimal integer like 0x8a, with a field width of 4;
c. A floating-point number like 2.33E+02, with a field width of 12, left-aligned;
d. A floating-point number like +232.346, with a field width of 10;
e. The first 8 characters of a string with a field width of 8.
Analysis and Answer:
a. The conversion specifier for unsigned integer is %u; for a long type field width, the l modifier should be added, the field width is 15, so the conversion specifier is %15lu;
b. The conversion specifier for hexadecimal integer data is %x (output lowercase letters using lowercase x), to output 0X use the # modifier; for a length of 4, use 4 as a modifier, so the conversion specifier is %#4x;
c. The conversion specifier for scientific notation is %E (output uppercase letters using uppercase E), left-aligned using the ‘-‘ modifier, field width is 12, displaying two decimal places using 12.2 modifier, so the conversion specifier is %-12.2E;
d. The conversion specifier for floating-point data is %f; display positive sign using ‘+’ modifier, field width is the character count in the number, meaning no specified field width, showing two decimal places using +0.2 modifier, so the conversion specifier is %+0.2f;
e. The conversion specifier for string is %s; field width is 8, showing the first 8 characters using 8.8 modifier, so the conversion specifier is %8.8s.
4) What conversion specifier should be used to print the following items?
a. A decimal number with a field width of 6, at least 4 digits;
b. An octal integer with field width specified in the parameter list;
c. A character with a field width of 2;
d. A floating-point number like +3.13, with a field width equal to the character count in the number;
e. The first 5 characters of a string with a field width of 7.
Analysis and Answer:
a. The conversion specifier for decimal integer is %d; field width is 6, at least 4 digits, using 6.4 modifier, so the conversion specifier is %6.4d;
b. The conversion specifier for octal data is %o; field width specified by the parameter list, using modifier ‘*’, so the conversion specifier is %*o;
c. The conversion specifier for character data is %c; field width is 2, using modifier 2, so the conversion specifier is %2c;
d. The conversion specifier for floating-point data is %f; display positive sign, field width is equal to the character count in the number, meaning no specified field width, displaying two decimal places using modifier +0.2, so the conversion specifier is %+0.2f;
e. The conversion specifier for string is %s; field width is 7, showing the first 5 characters, left-aligned, using modifier -7.5, so the conversion specifier is %-7.5s.
C language has developed from the early informal K&R standard to the 1990 ISO/ANSI standard, and then to the 2011 ISO/EC standard. This book has also gradually matured, developing to its current 6th edition. Throughout all these versions, my goal has been to write a strong, clear, and useful C language tutorial.
—— Author of the “C Primer Plus” series Stephen Prata
C Primer Plus 6th Edition Chinese Version
-
Click the image above to purchase “C Primer Plus 6th Edition Chinese Version”!
C Primer Plus 6th Edition Chinese Version Exercise Answers
-
Click the image above to purchase “C Primer Plus 6th Edition Chinese Version Exercise Answers”!
◆ While explaining the details of C language, programming concepts are also covered;
◆ Each time, short and simple examples are used to demonstrate one or two concepts, applying what you learn is one of the most effective ways to learn;
◆ When concepts are difficult to explain with words, diagrams are used to help readers understand;
◆ The main features of C language are summarized in boxes for easy reference and review;
◆ Each chapter ends with review questions and programming exercises to help readers test and deepen their understanding of C language.
— 03 —

Have You Started Learning C Language?
Participate in the interaction in the comment area, and click on ‘See’ and share the activity to your circle of friends. We will select 1 reader to receive a free book, deadline August 31.
Also welcome to join the asynchronous book review group for free reading of new books from time to time.

Asynchronous Book Review Group

Welcome to join the asynchronous reader group
