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
Do class declarations end with a semicolon? Do class method definitions?
List different attributes in C++?
Will a catch statement catch a derived exception if it is looking for the base class?
Describe public access specifiers?
Is vector a class in c++?
Why do we need runtime polymorphism in c++?
What data encapsulation is in c++?
What is ostream in c++?
What is the use of turbo c++?
How to declaring variables in c++?
Should a constructor be public or private?
What is the difference between the functions memmove() and memcpy()?
Why is c++ still best?
What is a type library?
Explain the difference between abstract class and interface in c++?