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...

int main()
{
int i ,a[i];
i = 0;
a[i] = 10;
cout<< a[i] << endl;
return 0;


}

What will be output of this program?

Answer Posted / rajesh

It will give segmentation fault(core dumped) - runtime error

This is not the way of declaring an array...a slight change
in program can correct it. Code below...

int main()
{
int i=0 ,a[i];
// i = 0;
a[i] = 10;
cout<< a[i] << endl;
return 0;
}
output : 10

please initialise the value of i before putting it in array
a[i]..this code will work fine and will give the output as 10.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are literals in C++?

978


How can you create a virtual copy constructor?

1031


What is the best c++ ide?

1080


What is polymorphism & list its types in c++?

1009


Write down the equivalent pointer expression for referring the same element a[i][j][k][l]?

1192


How is data hiding achieved in c++?

1023


Write about an iterator class?

1026


Describe Trees using C++ with an example.

1086


How do you clear a buffer in c++?

916


What is data type in c++?

967


What is ifstream c++?

978


What is the difference between a type-specific template friend class and a general template friend class?

930


What is meant by entry controlled loop?

1058


Why use of template is better than a base class?

1102


What is the maximum combined length of command line arguments including the space between adjacent arguments?

955