1)#include <iostream.h>
int main()
{
int *a, *savea, i;
savea = a = (int *) malloc(4 * sizeof(int));
for (i=0; i<4; i++) *a++ = 10 * i;
for (i=0; i<4; i++) {
printf("%d\n", *savea);
savea += sizeof(int);
}
return 0;
}
2)#include <iostream.h>
int main()
{
int *a, *savea, i;
savea = a = (int *) malloc(4 * sizeof(int));
for (i=0; i<4; i++) *a++ = 10 * i;
for (i=0; i<4; i++) {
printf("%d\n", *savea);
savea ++;
}
return 0;
}
The output of this two programs will be different why?
Answer Posted / mahesh
first program prints sum of saved and size of int
second one prints only the contenst of saved
Is This Answer Correct ? | 2 Yes | 3 No |
Post New Answer View All Answers
Define basic type of variable used for a different condition in C++?
Difference between overloaded functions and overridden functions
Will this c++ program execute or not?
Keyword mean in declaration?
Can a constructor return a value?
What are c++ templates used for?
What is the difference between delegation and implemented-in-terms-of?
Is dev c++ free?
What is pure virtual function? Or what is abstract class?
What are c++ tokens?
What are enumerations?
On throwing an exception by the animal constructor in p = new animalq, can memory leak occur?
Explain how would you handle a situation where you cannot call the destructor of a local explicitly?
Which recursive sorting technique always makes recursive calls to sort subarrays that are about half size of the original array?
Why do we learn c++?