C Language Exercises – Day 12

C Language Exercises - Day 12

01 Read the following program: #include <stdio.h> main() { int i,j, m=55; for(i=1;i<=3;i++) for(j=3; j<=i; j++) m=m%j; printf(“%d\n “, m); } The output of the program is A) 0 B) 1 C) 2 D) 3 Answer: B Explanation: Brief 02 Read the following program: main() { int a=5,b=4,c=3,d=2; if(a>b>c) printf(“%d\n”,d); else if((c-1>=d)==1) printf(“%d\n”,d+1); else printf(“%d\n”,d+2); … Read more

C Language Exercises – Day 15

C Language Exercises - Day 15

01 Read the following program: main() { int a=1, b=3, c=5; int *p1=&a, *p2=&b, *p3=&c; *p3=*p1*(*p2); printf(“%d\n”,c); } The output result after execution is A) 1 B) 2 C) 3 D) 4 Answer: C Analysis: Brief 02 To write a good program, it is essential to ensure its correctness and reliability, and also to emphasize … Read more

C Language Final Exam Programming Review

C Language Final Exam Programming Review

The C language final exam is on July 1st. Compared to the monthly exam, the number of questions for the final has significantly increased, with 15 multiple-choice questions and 5 programming questions. Therefore, when faced with programming questions, you should have an initial idea immediately upon seeing the question, and then proceed step by step … Read more

Does the C Language Hinder the Development of Microcontrollers?

Does the C Language Hinder the Development of Microcontrollers?

Recently,I often hear this question: Teacher,C is it too old? Will it hinder the development of microcontrollers? Now with Python and some new languages, is learning C a waste of time? 1.The C language indeed has its quirks. It is easy to make mistakes, such as misusing pointers, array out-of-bounds, forgetting to free memory… These … Read more

Design Patterns: Exploring Embedded C Language Implementation – 3. Decorator Pattern

Design Patterns: Exploring Embedded C Language Implementation - 3. Decorator Pattern

Series, click the above [Microcontroller and Microcontrol Development Journal] to follow this account to avoid losing it.Introduction: This article will briefly describe the Decorator Pattern from “Head First Design Patterns” and implement this pattern using C language. It will also explain the C language features used in the implementation;Background of the Decorator Pattern Implementation: Starbucks … Read more

The Modbus Savior for Embedded Developers: Full-Function Industrial Communication in 2000 Lines of Code!

The Modbus Savior for Embedded Developers: Full-Function Industrial Communication in 2000 Lines of Code!

Hello everyone, I am Mai Ge. In industrial automation and IoT device development, the Modbus protocol has become a commonly used standard for device communication due to its simplicity and reliability. However, efficiently implementing the Modbus protocol in resource-constrained embedded systems is often a significant challenge. This article will introduce a lightweight C language library … Read more

How to Learn C Language Programming for Embedded Systems?

How to Learn C Language Programming for Embedded Systems?

Everyone is quite familiar with the C language, but do you have this question: why, after learning C for so long, are you still stuck at the beginner level? I have seen many summaries of others’ programming experiences and found that most of them talk about their programming skills. Everyone knows that good programming skills … Read more

Detailed Explanation and Examples of Input and Output Stream Operations in C Language

Detailed Explanation and Examples of Input and Output Stream Operations in C Language

Detailed Explanation and Examples of Input and Output Stream Operations in C Language In C language, input and output (I/O) is the primary way for programs to interact with the external environment. Through the standard input-output library <span><stdio.h></span>, we can easily read and write data. This article will provide a detailed introduction to input and … Read more

C Language Exercises – Day 11

C Language Exercises - Day 11

01 The ASCII value of the digit character ‘0’ is 48. Given the following program: main() { char a=’1′,b=’2′; printf(“%c,”,b++); printf(“%d\n”,b-a); } The output of the program is: A) 3,2 B) 25,2 C) 2,2 D) 2,25 Answer: C Explanation: printf(“%c, b++): The initial value of b is ‘2’ (ASCII value 50); b++ is a post-increment, … Read more

C Language Exercise Class – Day 10

C Language Exercise Class - Day 10

01 Read the following program: void swap(char *x, char *y) { char t; t=*x; *x=*y; *y=t; } main() { char *s1=”abc”, *s2=”123″; swap(s1,s2); printf(“%s,%s\n”,s1,s2); } The output of the program is A) 123,abc B) abc,123 C) 1bc,a23 D) 321,cba Answer: C Analysis: The function swap works as follows: t = *x; saves the character pointed … Read more