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
Why cant I open a file by its explicit path?
write a c program to find the sum of five entered numbers using an array named number
What is memory leak in c?
Why is sprintf unsafe?
Explain about the constants which help in debugging?
What is use of pointer?
What is meant by high-order and low-order bytes?
Are the variables argc and argv are always local to main?
What is an auto keyword in c?
What is meant by int main ()?
Can I use base-2 constants (something like 0b101010)? Is there a printf format for binary?
What is pragma in c?
Write a program with dynamically allocation of variable.
Explain what is a program flowchart and explain how does it help in writing a program?
while initialization of array why we use a[][2] why not a[2][]...?