I_Interface
#define 5 6
Looks like #define true false :D
Dima
I think the warn limit would be 3
For such people as you meh
Ariana
Looks like #define true false :D
false isnt a thing is it #define true 0 maybe #define calloc malloc
I_Interface
Angie
Thank you. I did and I understand the rules
Anonymous
Hi
Hao 🦒
Hello!!
klimi
nohello.com
Hao 🦒
nohello.com
I will remember that 😂
klimi
well i think its fine to introduce but.. do it rather in Offtopic group
Anonymous
#ot
Anonymous
Hi
Anonymous
Hello
Anonymous
I have a beginner
Anonymous
Could anyone please help me with something
Anonymous
With c programming
Artöm
#howtoask
Anonymous
I was trying to calculate two integer numbers but when I scan the first variable as a float it suddenly gives me an unwanted number but if I scan the first number as an integer and the second number as a float it gives me the right answer (I notified the two variables as an integers )
Anonymous
int x,y; scanf(“%d”,&x); scanf(“%d”,&y); printf(“%d”,x+y);
Anonymous
int x,y; scanf(“%d”,&x); scanf(“%d”,&y); printf(“%d”,&x+y);
Anonymous
I know
Anonymous
But the problem is I am scanning not printing
Anonymous
So i can write whatever I want after running
Anonymous
I was trying to calculate two integer numbers but when I scan the first variable as a float it suddenly gives me an unwanted number but if I scan the first number as an integer and the second number as a float it gives me the right answer (I notified the two variables as an integers )
Anonymous
Yes i know it was a typing mistake
Anonymous
Can anyone tells me what’s wrong
Anonymous
Okay so when you taking float input how's you taking it
I_Interface
Can anyone tells me what’s wrong
https://stackoverflow.com/questions/37858125/input-double-precision-float-in-c/37859213
Anonymous
If I type 3.5 it suddenly gives me 12
olli
Wouldn't it be &x+&y
Why would it be? What's the purpose of adding the address of local variables?
Anonymous
But if I right at first 3 and then 4.5 it gives me a right answer
olli
If I type 3.5 it suddenly gives me 12
Can you please provide a full example including your source code as well as in- and output and expected behavior?
Anonymous
Okay
Anonymous
klimi
I though that %d is for digit
Anonymous
What happens when you input 3.3, 1 into this program?
Anonymous
Dima
Use floats
Anonymous
Anonymous
Non sense
I_Interface
Use floats
I gave the link for him -_-
Artöm
I though that %d is for digit
Decimal (d) or integer (i) are for ints
I_Interface
Non sense
https://stackoverflow.com/questions/37858125/input-double-precision-float-in-c/37859213
Dima
Are you silly or what
Dima
Use floats
Anonymous
When i type a decimal no at first it gives me a weird number but if i type a decimal no. It gives me the right answer
Mity
Decimal (d) or integer (i) are for ints
This is for decimal and decimal also called numeric
Anonymous
Okay i will but what’s wrong with that
Anonymous
Okay i will but what’s wrong with that
Console input is line buffered; when you enter 3.5 into a %d format specifier, only the 3 is consumed, the remaining data remains buffered, so the second scanf() call attempts to convert it according to its specifier, it finds a '.' and aborts the conversion leaving y undefined.
olli
When i type a decimal no at first it gives me a weird number but if i type a decimal no. It gives me the right answer
For every conversion specifier other than n, the longest sequence of input characters which does not exceed any specified field width and which either is exactly what the conversion specifier expects or is a prefix of a sequence it would expect, is what's consumed from the stream. The first character, if any, after this consumed sequence remains unread.
Anonymous
When i type a decimal no at first it gives me a weird number but if i type a decimal no. It gives me the right answer
This happens because the y's . is not problematic since it's never used from the buffer
Anonymous
I am not understanding
Anonymous
Sorry but I am a beginner
olli
I am not understanding
It is not a weird number, if you enter 3 and 2.5 it reads the first integer (3) and tries to read the second one and stops and the . since an integral value shall not contain this character, hence the second integer is 2. So the rsult is 5
Anonymous
Please simplify more, sorry for bothering you guys
Anonymous
But I really want to understand
Anonymous
But I really want to understand
Basically when you give 5.6 to an integer variable via scanf it only takes the first part 5
Anonymous
Got it?
Anonymous
Yes
Anonymous
Anonymous
Yes
Anonymous
But here it didnt give me the ability to scan Y
Anonymous
Because it thought the . was Y
Anonymous
And then to print both of the numbers
Anonymous
Ahaaa okayyy
Anonymous
But i didnt press enter
Anonymous
To scan Y after I typed 5.3
Anonymous
Idk about that
Anonymous
Please guys who knows?
Anonymous
It depends on your ide, you're using online that's y
Artöm
If you want to undestand what's going on, analyze return value of scanf