为您找到"
main( ) { int a; float b,c; printf(“input a b c:”); scanf(“%d...
"相关结果约100,000,000个
In this tutorial, you will learn to use scanf () function to take input from the user, and printf () function to display output to the user with the help of examples.
As the other people said, you need to use %f in the format string or convert a to an int. But I want to point out that your compiler, probably, knows about printf() 's format string and can tell you you're using it wrong.
In C, there are many functions used for input and output in different situations, but the most commonly used functions for Input/Output are scanf () and printf (), respectively.
Make the changes, then compile and run the program to make sure it works. Note that scanf uses the same sort of format string as printf (type man scanf for more info). Also note the & in front of a and b. This is the address operator in C: It returns the address of the variable (this will not make sense until we discuss pointers).
Learn how to take user input in C programming and how to display output in c programming. printf (), scanf (), getchar (), putchar (), gets () and puts () are the functions used for input and output of data in a C program.
The `printf` and `scanf` functions are fundamental in C programming, serving as the primary tools for outputting data and reading user input. Understanding their behavior in different scenarios is ...
To learn how to make the most of printf () and other input/output functions in C, explore our C programming course, which covers essential I/O operations in detail.
🛠️ Project 1: Student Record System (Using Structs + File Handling) Features: Add student data (name, roll number, marks) Save to file View all records #include #include
float数据精度以6位为准,超过6位的都是随机的。 还有,因为是2进制表示,所以小数不能精确表示,只能是近似值。 比如2进制1.1换成10进制是1.5,1.01换成10进制是1.25,所以2进制数无法表示1.1的准确值,有可能表示出来不是1.100000而是1.0999999
scanf () scanf () function is used in the C program for reading or taking any value from the keyboard by the user, these values can be of any data type like integer, float, character, string, and many more. This is a pre-defined function declared in stdio.h (header file).