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
What does the following do: for(;;) ; a) Illegal b) Loops forever c) Ignored by compiler...not illegal
What is increment operator in c++?
Describe about storage allocation and scope of global, extern, static, local and register variables?
What is function overloading c++?
What are stacks? Give an example where they are useful.
Can a constructor be private?
Should I learn c++ c?
To which numbering system can the binary number 1101100100111100 be easily converted to?
Why is c++ called oops?
Write a program to concatenate two strings.
What do you mean by friend class & friend function in c++?
If a function doesn’t return a value, how do you declare the function?
What's the hardest coding language?
What are the types of array in c++?
What is type of 'this' pointer? Explain when it is get created?