Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

C Language Examples - Output an integer

C Language Examples - Output an integer

C Language Examples C Language Examples

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 C Language Examples