C Language Examples - Output an integer
Use printf() and %d to format and output an integer.
Example
#include
<
stdio.h
int
main
(
)
{
int
number;
// printf() outputs a string
printf
(
"
Enter an integer:
"
)
;
// scanf() formats input
scanf
(
"
%d
"
, &
number
)
;
// printf() displays the formatted input
printf
(
"
The integer you entered is: %d
"
,
number
)
;
return
0
;
}
Output result:
输入一个整数: 45
你输入的整数是: 45
C Language Examples