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
When is the copy constructor called?
What is iterator c++?
What is an undefined behavior and sequence points
Write about the stack unwinding?
What is the use of this pointer in c++?
int age=35; if(age>80) {Console.WriteLine("Boy you are old");} else {Console.WrieLine("That is a good age");}
Is ca high or low level language?
How a macro differs from a template?
What is the need of a destructor?
What is meant by entry controlled loop? What all C++ loops are exit controlled?
If you want to share several functions or variables in several files maitaining the consistency how would you share it?
What is the oldest programming language?
Explain polymorphism?
What is jump statement in C++?
What is an orthogonal base class in c++?