what is the output of following question?
void main()
{
int i=0,a[3];
a[i]=i++;
printf("%d",a[i]
}
Answer Posted / ankur mohan sharma
A garbage value
Explanaiton:-since we have post increment operator applied on i. It's value gets incremented in next statement, so
a[i]=i++ means a[0]= 0
so a[0] is assigned value 0;
and now i becomes 1;
In next statement value of a[i] is to be printed which means value of a[1], which is not initialised. So value printed is a
garbage value.
Remarks
1. An uninitialised variable holds a garbage value.
2. Post increment operator increments value in next line.
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
in any language the sound structure of that language depends on its a) character set, input/output function, its control structures b) character set, library functions, input/output functions its control structures c) character set, library functions, control sturctures d) character set, operators, its control structures
Explain how do you determine whether to use a stream function or a low-level function?
What is difference between Structure and Unions?
what is the significance of static storage class specifier?
What is the difference between c and python?
Differentiate between a for loop and a while loop? What are it uses?
Why malloc is faster than calloc?
What is data structure in c language?
When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?
What is identifier in c?
How many keywords are there in c?
Tell us two differences between new () and malloc ()?
Is struct oop?
Is there a built-in function in C that can be used for sorting data?
Can I use base-2 constants (something like 0b101010)? Is there a printf format for binary?