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
What is the use of default constructor?
Which is better c++ or java?
Which one between if-else and switch is more efficient?
Give example of a pure virtual function in c++?
What is istream and ostream in c++?
What's the order in which the local objects are destructed?
Is c++ a programming language?
What is the type of 'this' pointer? When does it get created?
What are the syntactic rules to be avoid ambiguity in multiple inheritance?
What is the full form nasa?
What is an operator in c++?
What is the full form of c++?
Which ide is best for c++?
How do I make turbo c++ full screen?
Can I learn c++ as my first language?