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


Please Help Members By Posting Answers For Below Questions

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

670


Explain how do you determine whether to use a stream function or a low-level function?

616


What is difference between Structure and Unions?

632


what is the significance of static storage class specifier?

1650


What is the difference between c and python?

574






Differentiate between a for loop and a while loop? What are it uses?

658


Why malloc is faster than calloc?

580


What is data structure in c language?

597


When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?

575


What is identifier in c?

535


How many keywords are there in c?

583


Tell us two differences between new () and malloc ()?

608


Is struct oop?

573


Is there a built-in function in C that can be used for sorting data?

737


Can I use base-2 constants (something like 0b101010)? Is there a printf format for binary?

569