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 the 3 levels of programming languages?

1041


How do I run a program in notepad ++?

1096


What is static function? Explain with an example

1067


Why do we need templates?

988


What is a container class? What are the types of container classes in c++?

1251


When there is a global variable and local variable with the same name, how will you access the global variable?

1094


Can you please explain the difference between using macro and inline functions?

1039


Can we make copy constructor private in c++?

1048


Define the process of error-handling in case of constructor failure?

1011


Is c++ a float?

1058


What do you understand by pure virtual function? Write about its use?

997


Write a program using display() function which takes two arguments.

1063


Differentiate between a copy constructor and an overloaded assignment operator.

1072


What is object oriented programming (oop)?

1109


How would you use the functions randomize() and random()?

1071