This series of articles will be taught in easy-to-understand dialogues that will cover common problems for beginners. This series will continue to be updated, including the use of dialogue in other languages as well as in the real world. Basic programming language teaching is applicable to the zero-based students, and the real world curriculum will be gradually updated.
If there is something you want to learn, you can leave a message in the comments section and keep updating according to your request. I’ll update the next one if I get 100, 000 likes. (Definitely not, and more.)
If you have any questions, leave them in the comments section.
If you like the content, welcome to follow me, comment, like, favorites, this is very important to me, thank you ~
directory
If I ask basic questions in a big group, no one will listen? “Peep big talk chat record to learn C language” (2) I said programming is easy to defy you? “Peep big talk chat record learn C language” (3) code are in love don’t you know? “Peep big talk chat record to learn C language” (4) originally I would program “peep big talk chat record to learn C language” (5) played a game I learned a programming knowledge?
Author’s brief introduction
Author name: 1_bit introduction: CSDN blog expert, 2020 TOP5 blog stars
directory
If I ask basic questions in a big group, no one will listen? “Peep big talk chat record to learn C language” (2) I said programming is easy to defy you? “Peep big talk chat record learn C language” (3) code are in love don’t you know? “Peep big talk chat record to learn C language” (4) originally I can program early
👸 small yuan: small C, I come again. Ha ha ha, is not to see me feel very horrible, after all, I come to trouble you every day. 😅
🐰 small C: ha ha ha, no matter, recently my task is to teach you the C language of the entry, so want to learn can come to me. 😀
👸 small yuan: ha ha ha, that I don’t mention it, that today learn what content?
🐰 Little C: Today let’s learn the basic variables of C language?
👸 xiaoyuan: will it be difficult? 😰
🐰 Little C: It won’t be hard. C basic variables you can think of as containers, different types of containers can hold different types of content.
👸 Xiaoyuan: You mean like water bottles used to hold water, lunch boxes used to hold rice? 😦
🐰 C: Ha ha ha, your analogy is quite appropriate, but we also need to consider other situations. Like what happens when there’s rice in a water bottle.
👸 Xiaoyuan: Ah! It feels like this question is suddenly very complicated. 😭
🐰 C: No, let me tell you about variables of integer type in C language.
👸 Xiaoyuan: I suddenly think of a question, integer type variable is not a container can hold an integer? Why do integers fit into containers? 😰
🐰 small C: ha ha ha, this question but asked me. It can be said that number is an abstract concept, something that does not exist in our real life, and is born from human experience. We do the same thing with programming, which doesn’t exist in real life, where we define something abstract as a container, and then that container can hold an integer. Does that make sense to you? 😐
👸 Xiaoyuan: You mean, just like me and Xiao Ming drawing on a piece of paper, I and he stipulated that the circle is a container, and we can fill it with integers, so we can treat the circle on the paper as a container? 😱
🐰 small C: ha ha ha, yes, it seems that you are quite smart, we can be so one-sided to understand the concept of this variable. We create a variable in C language is very simple, write int means integer type in the code, then write int type identifier in a variable name before it is created a variable, such as int a, but note that we are creating a type, must be to create a variable after the latest of a value, This process of giving a value is called initialization; Such as “int a = 100;” , note that the end is marked with a semicolon. In this example, int means that the variable to be created is an integer, and a is the name of the variable. Using the equals sign gives the value to the right of the equals sign to the left of the equals sign to a, which stores a value of 100.
👸 xiaoyuan: seems really quite simple, that I write “int a=10;” Is it this variable a that stores 10?
🐰 Small C: Yes, it is very simple, then we continue.
👸 Xiaoyuan: Ok, sit back and absorb new knowledge. 😋
🐰 Little C: How do we use the integer variable a once we have created it?
👸 Xiaoyuan: I don’t know. 😰
🐰 Little C: Easier to use. As we said a couple of times ago, printf is used to display what we want to display. You can also use printf to display the values stored in a.
👸 small yuan: we are not know a inside save what, why also output show? 😒
🐰 small C: Let’s put it this way, if you develop a game, there are a lot of weapons and equipment, all the weapons of attack are written by you, but when you take your game to others to play, do you need to show it to tell these players?
👸 xiaoyuan: Huh? That seems to be the idea. 😳
🐰 small C: So, we write the program of course know the numerical case we write, but the user does not know, so we have to learn this method, or we will not use it later.
👸 Xiaoyuan: Yes, I see.
🐰 little C: It’s easy to use printf to display the contents of variable A. The code looks like this: printf(“%d”,a); .
👸 Xiaoyuan: Waka! It’s hard. I don’t understand. A bunch of symbols have big heads. 😵
🐰 small C: No, I’m asking you now, should you instruct printf how to display the content you want to display?
👸 Xiaoyuan: Yes, I know. Just put whatever you want in the printf parentheses. For example, “printf(” what you want to display”); .
🐰 small C: Let me ask you, “printf(“%d”);” What’s going to be displayed?
👸 xiaoyuan: not % D? 😰
🐰 small C: ha ha ha, really not. %d in C represents a placeholder, which means to occupy a position here that will be replaced with a value later.
👸 Xiaoyuan: I don’t understand. 😶
🐰 little C: Let’s look at the parentheses in the code I just said “%d”,a “. There is also a comma and a variable name after %d enclosed by double quotes in parentheses. When the C program outputs content, it replaces %d with the contents of the variables separated by the first comma after the double quotation marks, meaning that whatever value is stored in a is displayed.
👸 Xiaoyuan: Oh ~ that’s what it means. 😎
🐰 small C: I give you a look at the complete code and running results, you try it yourself.
#include<stdio.h>
#include<stdlib.h>
void main(a){
int a=10;
printf("%d",a);
system ("pause");
}
Copy the code
👸 xiaoyuan: Good, I succeeded ~
🐰 small C: you digest it first, knowledge points haven’t finished speaking, etc.
Princess: Yes, 😯