0

Why is the output of int and float always 2358860 and 0.0000000?

#include <stdio.h> int main() { int x; float num; char text[20]; scanf("%d %f %s", &x, &num, text); printf("%d %f %s", &x, &num, text); /*Why does the output of any input always equal 2358860, 0.000000, but the text is accurate. */ }

4th Jun 2019, 6:58 PM
Ryan Stewart
4 Answers
+ 7
you're printing the address where the value is been stored
4th Jun 2019, 7:13 PM
✳AsterisK✳
✳AsterisK✳ - avatar
+ 2
Because & operator is used to print the address .
5th Jun 2019, 5:49 AM
Yashvi Shah
Yashvi Shah - avatar
+ 2
Thanks everyone, didn't realize the purpose of the address specifier this early on
5th Jun 2019, 12:32 PM
Ryan Stewart
+ 1
Because you shouldn't use the & operator within the printf.
4th Jun 2019, 7:02 PM
Andres0b0100
Andres0b0100 - avatar