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

Define the operators that can be used with a pointer.

994


What is the return value of the insertion operator?

1083


What is an inclusion guard?

1110


What are structs in c++?

968


Write a program to concatenate two strings.

1028


Why the usage of pointers in C++ is not recommended ?

1345


Why is c++ still used?

1012


When do we run a shell in the unix system? How will you tell which shell you are running?

917


Explain one-definition rule (odr).

1066


How to demonstrate the use of a variable?

1048


Explain dangling pointer.

1074


What are associate containers?

976


What is meant by iomanip in c++?

1126


What is a set in c++?

918


Are c and c++ similar?

997