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


1. What does the following do:

void afunction(int *x)
{
x=new int;
*x=12;
}
int main()
{
int v=10;
afunction(&v);
cout<<v;
}
a) Outputs 12
b) Outputs 10
c) Outputs the address of v

Answer Posted / shakti singh khinchi

ANs: b. Output is 10.

bcoz in method afunction() allocates new memory to var x and
change its value after that, but tha actual variable doesn't
changes its location, thats why its remains same as it has
initialised by 10.

But if memory allocation by "new" has not ben done than it
will change the value as 12.

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are enumerations?

1149


What is a list c++?

1158


Who invented turbo c++?

1115


Explain how overloading takes place in c++?

1097


In which header file does one find isalpha() a) conio.h b) stdio.h c) ctype.h

1259


Write about c++ storage classes?

1252


What does return 0 do in c++?

1084


Why we use #include conio h in c++?

1103


What are static member functions?

1159


What is token c++?

1091


What is pointer -to-members in C++? Give their syntax?

1079


How does list r; differs from list r();?

1200


On throwing an exception by the animal constructor in p = new animalq, can memory leak occur?

1187


What are the uses of typedef in a program?

1135


What is difference between rand () and srand ()?

1150