Input & output methods | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок

Input & output methods

Is scanf() is used to take input from user of type integer only or any other data type also...?

25th Feb 2020, 2:09 AM
Lokesh Jammi
Lokesh  Jammi - avatar
4 ответов
You can use a format specifier for what data type of input you want from the user.e.g if you want an int input from the user then, int x; scanf("%d", &x); here we %d format specifier because we want int input from user.
25th Feb 2020, 2:46 AM
Maninder $ingh
Maninder $ingh - avatar
+ 3
Yes its also use for other data type , Like in integer input int a; scanf("%d",&a); For float float a; scanf("%f",&a); So you see the changes only specifier is change . specifier is : int :d&i float:f char:c string:s long int:ld
25th Feb 2020, 2:49 AM
Prathvi - avatar
+ 1
Maninder $ingh ThankYou, Understood now 👍
25th Feb 2020, 2:47 AM
Lokesh Jammi
Lokesh  Jammi - avatar
Prathvi ThankYou 👍
25th Feb 2020, 2:51 AM
Lokesh Jammi
Lokesh  Jammi - avatar