Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Why cant I open a file by its explicit path?

1086


write a c program to find the sum of five entered numbers using an array named number

2205


What is memory leak in c?

1175


Why is sprintf unsafe?

1132


Explain about the constants which help in debugging?

1420


What is use of pointer?

1172


What is meant by high-order and low-order bytes?

1102


Are the variables argc and argv are always local to main?

1082


What is an auto keyword in c?

1146


What is meant by int main ()?

1255


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

1057


What is pragma in c?

1283


Write a program with dynamically allocation of variable.

1183


Explain what is a program flowchart and explain how does it help in writing a program?

1143


while initialization of array why we use a[][2] why not a[2][]...?

2402