Why we use %d in scanf() Function? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why we use %d in scanf() Function?

Scanf()

7th Sep 2021, 7:38 AM
Amin
Amin - avatar
5 Answers
+ 9
You can, they are the same for printf, but there is a slight difference with scanf. Read this; https://www.google.com/amp/s/www.geeksforgeeks.org/difference-d-format-specifier-c-language/amp/
7th Sep 2021, 7:52 AM
ChaoticDawg
ChaoticDawg - avatar
+ 6
%d is a format specifier that means you want to receive an integer (decimal/base 10).
7th Sep 2021, 7:44 AM
ChaoticDawg
ChaoticDawg - avatar
+ 2
Thanks bro ❤
7th Sep 2021, 7:59 AM
Amin
Amin - avatar
0
Why don't we use %i instead?
7th Sep 2021, 7:49 AM
Amin
Amin - avatar
0
we use %d to scan the entered value, and that value should be an int.
8th Sep 2021, 1:40 PM
Jocelin Kisenga
Jocelin Kisenga - avatar