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

Explain the auto storage classes in c++.

1103


Describe about storage allocation and scope of global, extern, static, local and register variables?

1259


Can turbo c++ run c program?

1098


Can you explicitly call a destructor on a local variable?

1030


Can constructor be static in c++?

1115


What can c++ be used for?

1101


Write a note about the virtual member function?

1058


What are vectors used for in c++?

1076


Describe friend function & its advantages.

1135


What is & in c++ function?

1064


What is the real purpose of class – to export data?

1113


When you overload member functions, in what ways must they differ?

1048


Are there interfaces in c++?

1018


Will rust take over c++?

1060


How can I disable the "echo" feature?

1176