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

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

792


Which programming language should I learn first?

816


What does the following code do: int c=0; cout< a) Undefined *Updated* b) 01 c) 00

859


When do you call copy constructors?

913


Specify some guidelines that should be followed while overloading operators?

901


What is data types c++?

809


What is a buffer c++?

821


What are references in c++? What is a local reference?

806


What is the sequence of destruction of local objects?

764


What is microsoft c++ redistributable?

831


What is data type in c++?

787


Which software is best for programming?

911


Search for: what is pair in c++?

910


What are separators in c++?

861


What is a multimap c++?

913