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
What is the use of function overloading in C?
any "C" function by default returns an a) int value b) float value c) char value d) a & b
How can I ensure that integer arithmetic doesnt overflow?
a character or group of characters that defines a register,or a part of storage a) memory b) byte c) address d) linear list
What is context in c?
What does s c mean on snapchat?
write a c program to print the next of a particular no without using the arithmetic operator or looping statements?
Explain how do you print an address?
What is the use of volatile?
The performance of an operation in several steps with each step using the output of the preceding step a) recursion b) search c) call by value d) call by reference
How can a program be made to print the line number where an error occurs?
the statement while(i) puts the entire logic in loop. this loop is called a) indefinite loop b) definite loop c) loop syntax wrong d) none of the above
Write a program to implement queue.
What is the difference between constant pointer and constant variable?
Why & is used in c?