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
Name the implicit member functions of a class.
What is a c++ map?
What does the following do: for(;;) ; a) Illegal b) Loops forever c) Ignored by compiler...not illegal
What is c++ good for?
Explain the uses of static class data?
What is buffer and example?
What is the type of 'this' pointer?
How compile and run c++ program in turbo c++?
What is the use of c++ programming language in real life?
What is public, protected, private in c++?
Define 'std'.
What ANSI C++ function clears the screen a) clrscr() b) clear() c) Its not defined by the ANSI C++ standard
Can user-defined object be declared as static data member of another class?
Why is it called c++?
Can we distribute function templates and class templates in object libraries?