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

Explain virtual class?

1021


Does std endl flush?

1024


What do you mean by volatile and mutable keywords used in c++?

968


Describe the role of the c++ in the tradeoff of safety vs. Usability?

1201


How much do c++ programmers make?

1094


How do I write a c++ program?

1104


Write about the role of c++ in the tradeoff of safety vs. Usability?

1048


What c++ is used for?

1054


What is main function in c++ with example?

1208


How to access a variable of the structure?

1068


What are the different types of polymorphism in c++?

1118


How many types of modularization are there in c++?

1066


What is the difference between a pointer and a link in c ++?

1045


Draw a flow chart and write a program for the difference between the sum of elements with odd and even numbers. Two dimensional array.

6397


What relational operators if statements in c++?

1160