0
The output was 40 how it possible
#include <iostream> using namespace std; int main() { int x,d,k; d=5; k=x*d; cout << k; }
4 ответов
+ 6
That's because you are using an uninitialized variable in your expression which is x.
x will have some garbage value which is multiplied by d(5) and assigned to the variable k.
It's a good practice to initialize variables at the time of their declaration to avoid any logical errors.
+ 4
No it will be different in every device.
What happens is, some program uses memory and when it exits, that memory is freed (available for use by other programs).
Now there could be a chance that a variable that you created in your program will point to the part of memory location which was used by the previous program. Now that memory address is holding some garbage value which is also pointed by the same variable you created. So, now that variable has garbage value in it.
+ 3
nAutAxH AhmAd
Does the x takes the value of 8 in any device (ie., does the garbage value of x is the same in any device) coz I get the same result of 40
0
Anybody please answer me I am very confused