当前位置:网站首页>C language - first program, print, variables and constants
C language - first program, print, variables and constants
2022-07-27 02:22:00 【Lydialyy】
Catalog
One 、C Characteristics of language :
Four 、 Variables and constants
One 、C Characteristics of language :
High flexibility 、 Efficient 、 High portability
Two 、 The first program
1. Software :Dev-C++ 5.11
2. step :
file → newly build → Source code
function → Compile operation →( Save type )C source files(*.c)→( file name )test.c→ preservation
#include <stdio.h>
int main()
{
printf("Hello World\n");
return 0;
}3. Code run results

3、 ... and 、 Escape character
| Escape character | meaning |
| \a | Ring the bell (BEL) |
| \b | Backspace (BS), Move the current position to the previous column |
| \f | Change the page (FF), Move the current position to the beginning of the next page |
| \n | Line break (LF), Moves the current position to the beginning of the next line |
| \r | enter (CR), Move the current position to the beginning of the line |
| \t | Horizontal TAB (HT), Skip to the next TAB Location |
| \v | Vertical tabulation (VT) |
| \\ | Indicates that the backslash itself (\) |
| \' | For single quotes (’) |
| \" | Double quotation marks (") |
| \? | Indicates a question mark (?) |
| \0 | For empty characters (NULL) |
| \ddd | 1 To 3 Any character represented by an octal number |
| \xhh | 1 To 2 Any character represented by hexadecimal digits |
Four 、 Variables and constants
Variables and constants are two basic data objects processed by programs .
1. Variable
(1) The meaning of variable is to determine the target and provide storage space .
(2) Variable name : Variable names can only be in English letters (A-Z,a-z) And number (0-9) Or underline (_) form .
Naming rules :① The first letter must start with a letter or an underline ;
② Variable names are case sensitive ;
eg:_FISHC ≠ fishc
③ You cannot use keywords to name variables .
(3) keyword
| auto | break | case | char | const | continue | default | do |
| double | else | enum | extern | float | for | goto | if |
| int | long | register | return | short | signed | sizeof | static |
| struct | switch | typedef | union | unsigned | void | volatile | while |
| inline | restrict | _Bool | _Complex | _Imaginary |
| _Alignas | _Alignof | _Atomic | _Static_assert | _Noreturn | _Thread_local | _Generic |
(4) data type
- char — Character , Take up one byte
- int — integer , It usually reflects the most natural length of an integer in the machine used
- float — Single precision floating point
- double — Double precision floating point
eg:int a;char b;float c;double d
(5) Code :
#include <stdio.h>
int main()
{
int a;
char b;
float c;
double d;
a = 520;
b = 'F';
c = 3.14;
d = 3.141592653;
printf(" fish C The studio was founded in 2010 Year of %d\n",a);
printf("I love %cishC.com!\n",b);
printf(" PI is :%.2f\n",c);
printf(" Accurate to the decimal point 9 The Pi of bit is :%11.9f\n",d);
return 0;
}Running results :

2. Constant
- integer constants :520,1314,123
- Real constant :3.14,5.12,8.97
- character constants : Ordinary character :'L','O','V','E'; Escape character :'\b','\t','\n'
- String constant :“FishC”
- Symbolic constant : You must define before using
3. Define symbolic constants
(1) Format :#define identifier Constant
such as :- #define URL"http://www.fishc.com"
- #define NAME" fish C Studio ”
- #define BoSS“ Little turtle ”
- #define YEAR 2010
- #define MONTH5
- #define DAY 20
Code :
#include <stdio.h>
#define URL "http://www.fishc.com"
#define NAME " fish C Studio "
#define BOSS " Little turtle "
#define YEAR 2010
#define MONTH 5
#define DAY 20
int main()
{
printf("%s Founded on %d year %d month %d Japan \n",NAME,YEAR,MONTH,DAY);
printf("%s yes %s Created ……\n",NAME,BOSS);
printf("%s The domain name of is %s\n",NAME,URL);
return 0;
}Running results :

(2) identifier (identifier)
- Identifiers can only be English letters (A-Z,a-z) And number (0-9) Or underline (_) form (eg:_ i_love_fishC_520)
- The first letter must start with a letter or an underline
- Identifiers are case sensitive (eg:_ FISHC ≠ fishc)
- You cannot use keywords to name identifiers
(3) String constant
- character :'F','I','S','H','C'
| 'F' | 'I' | 'S' | 'H' | 'C' |
- character string :
——"Hello World"
| 'H' | 'e' | 'l' | 'l' | 'o' | ' ' | 'W' | 'o' | 'r' | 'l' | 'd' | '\0' |
——"I love FishC.com!"
| 'I' | ' ' | 'l' | 'o' | 'v' | 'e' | ' ' | 'F' | 'i' |
| 's' | 'h' | 'C' | '.' | 'c' | 'o' | 'm' | '!' | '\0' |
边栏推荐
- Nat网络地址转换实验
- 6.29 Zhong'an Summer Internship
- Educational Codeforces Round 132 (Rated for Div. 2), problem: (D) Rorororobot
- Dynamic routing rip protocol experiment
- Golang - sync包的使用 (WaitGroup, Once, Mutex, RWMutex, Cond, Pool, Map)
- 光光光仔的CSDN之旅
- OSPF protocol knowledge summary
- Esp8266wi fi access cloud platform
- Experiment of OSPF in mGRE environment
- NAT network address translation experiment
猜你喜欢
随机推荐
CAN总线通信应用
CF 1333C Eugene and an array
睡不着时闭眼躺着,到底有没有用?
Lecture 3 - GPIO input / output library function usage and related routines
Esp8266wi fi access cloud platform
Static comprehensive experiment (comprehensive exercise of static route, loopback interface, default route, empty interface, floating static)
[Database Course Design] SQLSERVER database course design (student dormitory management), course design report + source code + database diagram
RS-485 bus communication application
SQL优化的N种方法
Codeforces Round #809 (Div. 2), problem: (C) Qpwoeirut And The City
TCP's three handshakes and four waves (brief introduction)
Republishing and routing strategy of OSPF
HCIA静态路由基础模拟实验
Experiment of OSPF in mGRE environment
Ogeek meetup phase I, together with cubefs, is hot
Lvs+keepalived project practice
Codeforces Round #807 (Div. 2), problem: (C) Mark and His Unfinished Essay
HCIA基础知识(1)
NB-IOT联网通信
【C语言】阶乘实现









