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

What is the best free c++ compiler for windows?

837


Can you pass an array to a function in c++?

769


What is boyce codd normal form in c++?

920


Which is most difficult programming language?

800


What is the difference between struct and class?

1069


Specify different types of decision control statements?

605


What is the basic structure of a c++ program?

838


What is a pdb file?

760


Explain how overloading takes place in c++?

777


Reads in the size of a square from the screen; 2. Prints a hollow square of that size out of “-“, “|” and blanks on screen; 3. Prints the same hollow square onto a text file. Your program should work for squares of all side sizes between 1 and 20. --- │ │ │ │ │ │ ---

1878


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

832


Can I learn c++ as my first language?

860


What is the identity function in c++? How is it useful?

798


What is the limitation of cin while taking input for character array?

1739


What is microsoft c++ redistributable 2013?

816