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


Please Help Members By Posting Answers For Below Questions

When is the copy constructor called?

627


What is iterator c++?

543


What is an undefined behavior and sequence points

563


Write about the stack unwinding?

624


What is the use of this pointer in c++?

566






int age=35; if(age>80) {Console.WriteLine("Boy you are old");} else {Console.WrieLine("That is a good age");}

828


Is ca high or low level language?

580


How a macro differs from a template?

633


What is the need of a destructor?

635


What is meant by entry controlled loop? What all C++ loops are exit controlled?

558


If you want to share several functions or variables in several files maitaining the consistency how would you share it?

550


What is the oldest programming language?

564


Explain polymorphism?

581


What is jump statement in C++?

613


What is an orthogonal base class in c++?

650