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 difference between void main and main in c?
Write a program, where i have a grid with many cells, how many paths are possible from one point to other desired points.
Is sizeof a keyword in c?
Can the curly brackets { } be used to enclose a single line of code?
How do you view the path?
How to check whether string is a palindrome, WITHOUT USING STRING FUNCTIONS?
Why c language is called c?
Does * p ++ increment p or what it points to?
What type of function is main ()?
Why do we use stdio h and conio h?
State two uses of pointers in C?
What is the time and space complexities of merge sort and when is it preferred over quick sort?
How would you obtain the current time and difference between two times?
List some applications of c programming language?
What are the loops in c?