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




Answers were Sorted based on User's Feedback



1. What does the following do: void afunction(int *x) { x=new int; *x=12; } int main(..

Answer / guest

Ten(10) is the out put

Is This Answer Correct ?    8 Yes 0 No

1. What does the following do: void afunction(int *x) { x=new int; *x=12; } int main(..

Answer / ranjeet garodia

b is correct

Is This Answer Correct ?    8 Yes 0 No

1. What does the following do: void afunction(int *x) { x=new int; *x=12; } int main(..

Answer / 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




1. What does the following do: void afunction(int *x) { x=new int; *x=12; } int main(..

Answer / arun pateel

Answer is b

Is This Answer Correct ?    1 Yes 0 No

1. What does the following do: void afunction(int *x) { x=new int; *x=12; } int main(..

Answer / manish podiyal

C): outputs the address of v.

Is This Answer Correct ?    1 Yes 8 No

Post New Answer



More C++ General Interview Questions

What are the two main components of c++?

0 Answers  


What is a type library?

0 Answers  


What is &x in c++?

0 Answers  


How c functions prevents rework and therefore saves the programers time as wel as length of the code ?

0 Answers  


The "virtual" specifier in a member function enables which one of the following? a) Monmorphism b) Late binding c) Metamorphism d) Solomorphism e) Inheritance

4 Answers   Quark,






How do you traverse a btree in backward in-order?

0 Answers  


What is atoi in c++?

0 Answers  


Can member data be public?

0 Answers  


Tell me an example where stacks are useful?

0 Answers  


How can a '::' operator be used as unary operator?

1 Answers  


an integer constant must have atleast one a) character b) digit c) decimal point

0 Answers  


What are destructors?

0 Answers  






Categories