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 implicit conversion/coercion in c++?
What is difference between class and structure in c++?
What is srand c++?
How do you save a c++ program?
Explain the difference between class and struct in c++?
Define the process of handling in case of destructor failure?
Which software is used for c++ programming?
Write a short code using c++ to print out all odd number from 1 to 100 using a for loop
Why do we use vector in c++?
What is the difference between new() and malloc()?
Is c++ a high level language?
Tell me what are static member functions?
Is java the same as c++?
What are references in c++?
How do I get good at c++ programming?