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

Does c++ have a hash table?

656


What is type of 'this' pointer?

690


How const int *ourpointer differs from int const *ourpointer?

693


If a header file is included twice by mistake in the program, will it give any error?

648


Explain the use of vtable.

716






What is the difference between prefix and postfix versions of operator++()?

694


Define basic type of variable used for a different condition in C++?

759


How did c++ start?

703


How do you import payscale data from non SAP to SAP?is it through LSMW or any other way is there?

3296


How did c++ get its name?

661


What is the benefit of c++?

695


Write a program using display() function which takes two arguments.

702


What is DlgProc?

685


What are smart pointers?

778


What is encapsulation in c++ with example?

667