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

Can we inherit constructor in c++?

592


What will strcmp("Astring", "Astring"); return a) A positive value b) A negative value c) Zero

641


Is c++ the most powerful language?

571


What is meant by the term name mangling in c++?

524


Name the operators that cannot be overloaded in C++?

587






What are put and get pointers?

585


What's the hardest coding language?

577


what is C++ exceptional handling?

633


What is the difference between cin.read() and cin.getline()?

563


Does improper inheritance have a potential to wreck a project?

634


What is the outcome of cout< a) 16 b) 17 c) 16.5

629


How to declaring variables in c++?

663


Can I learn c++ without learning c?

564


What is the type of 'this' pointer? When does it get created?

552


Can the operator == be overloaded for comparing two arrays consisting of characters by using string comparison?

569