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
Does c++ have a hash table?
What is type of 'this' pointer?
How const int *ourpointer differs from int const *ourpointer?
If a header file is included twice by mistake in the program, will it give any error?
Explain the use of vtable.
What is the difference between prefix and postfix versions of operator++()?
Define basic type of variable used for a different condition in C++?
How did c++ start?
How do you import payscale data from non SAP to SAP?is it through LSMW or any other way is there?
How did c++ get its name?
What is the benefit of c++?
Write a program using display() function which takes two arguments.
What is DlgProc?
What are smart pointers?
What is encapsulation in c++ with example?