In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article is to share with you about what the C language variable is. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
Introduction of C language variables
The variable is equivalent to the representation of a data storage space in memory, you can think of the variable as the house number of a room, we can find the room through the house number, and the variable (value) can be accessed through the variable name.
Basic steps for using variables
1) declare variables
Int num
2) assignment
Num = 60
3) use
Printf ("num=%d", num)
4) it can also be achieved in one step: int num2 = 99
Case study of getting started with variable
Look at the demo and explain the code
/ / 1. Declare a variable [tell the computer to open a room]
Int num = 1; / / Integer
Double score = 2.3; / / decimal
Char gender = 'Aids; / / character
Char name [] = "Qingyu"; / / string
# include void main () {int num = 1; double score = 123; char sex='N'; char name [] = "Qingyu" / / output / * if output is integer% d if output is decimal% f, keep two decimal places% .2f if output is character% c if output is string% s * / output different data with% s * / / The corresponding format should correspond to printf ("num=%d,score=%.2f,sex=%c,name=%s", num,score,sex,name). Notes on the use of getchar ();} variables
1) the variable represents a storage area in memory (different data types take up different amounts of space)
2) the area has its own name and type
3) variables must be declared before using
4) the data in this area can be constantly changed within the same type.
5) variables cannot have the same name in the same scope
6) three elements of variables (variable name + value + data type), please pay attention to this.
Thank you for reading! This is the end of this article on "what are C language variables?". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.