What is the output of printf("%d")?
Answers were Sorted based on User's Feedback
Answer / sathiyaraj.m
it will print the garabage value,it will not show any error
Is This Answer Correct ? | 3 Yes | 1 No |
Answer / arun katal
it's only print value 'o' or if we take any variable
with define it print define value of variable.
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / hafizul
the value at the top of the stack will be printed.
if some value is assigned to some variable before dis stmnt
then that value will be printed, otherwise some garbage
value(that r at the top of the stack) will be printed.
Is This Answer Correct ? | 2 Yes | 1 No |
Answer / masquerade
for int and char specifier it prints garbage value
and for float it will give error
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / arvind kumar yadav
When we use %d the compiler internally uses it to access
the argument in the stack (argument stack). Ideally
compiler determines the offset of the data variable
depending on the format specification string. Now when we
write printf("%d",a) then compiler first accesses the top
most element in the argument stack of the printf which is %
d and depending on the format string it calculated to
offset to the actual data variable in the memory which is
to be printed. Now when only %d will be present in the
printf then compiler will calculate the correct offset
(which will be the offset to access the integer variable)
but as the actual data object is to be printed is not
present at that memory location so it will print what ever
will be the contents of that memory location.
Is This Answer Correct ? | 1 Yes | 0 No |
Answer / kanchan
%d prints integer value but we have to provide corresponding variable with it i.e..
printf("%d" n) here it prints value of n which is of integer type
printf("%d") will create a garbage value b'coz copiler is unknown of associated variable.
Is This Answer Correct ? | 1 Yes | 0 No |
What is purpose of new operator?
Write a program to reverse a linked list?
8 Answers Catalytic Software, Satyam,
What are the 4 types of library?
What is compilation?
What is namespace & why it is used in c++?
Is it possible to use a new for the reallocation of pointers ?
What does h mean in maths?
Is c++ platform dependent?
What is general form of pure virtual function? Explain?
What is c++ course?
Differentiate between an array and a list?
Describe Trees using C++ with an example.