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

Name the implicit member functions of a class.

847


What is a c++ map?

958


What does the following do: for(;;) ; a) Illegal b) Loops forever c) Ignored by compiler...not illegal

947


What is c++ good for?

780


Explain the uses of static class data?

853


What is buffer and example?

723


What is the type of 'this' pointer?

801


How compile and run c++ program in turbo c++?

863


What is the use of c++ programming language in real life?

786


What is public, protected, private in c++?

885


Define 'std'.

926


What ANSI C++ function clears the screen a) clrscr() b) clear() c) Its not defined by the ANSI C++ standard

803


Can user-defined object be declared as static data member of another class?

783


Why is it called c++?

788


Can we distribute function templates and class templates in object libraries?

804