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 / shil chawla

the program will not RUN becoz #include<iostream.h>
does not support "printf()".

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Do class declarations end with a semicolon? Do class method definitions?

614


List different attributes in C++?

639


Will a catch statement catch a derived exception if it is looking for the base class?

556


Describe public access specifiers?

579


Is vector a class in c++?

594






Why do we need runtime polymorphism in c++?

555


What data encapsulation is in c++?

593


What is ostream in c++?

567


What is the use of turbo c++?

551


How to declaring variables in c++?

657


Should a constructor be public or private?

535


What is the difference between the functions memmove() and memcpy()?

626


Why is c++ still best?

550


What is a type library?

684


Explain the difference between abstract class and interface in c++?

521