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 is the best free c++ compiler for windows?
Can you pass an array to a function in c++?
What is boyce codd normal form in c++?
Which is most difficult programming language?
What is the difference between struct and class?
Specify different types of decision control statements?
What is the basic structure of a c++ program?
What is a pdb file?
Explain how overloading takes place in c++?
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. --- │ │ │ │ │ │ ---
What does the following code do: int c=0; cout< a) Undefined *Updated* b) 01 c) 00
Can I learn c++ as my first language?
What is the identity function in c++? How is it useful?
What is the limitation of cin while taking input for character array?
What is microsoft c++ redistributable 2013?