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
Describe new operator?
What do you mean by storage classes?
What is late binding c++?
Is c++ the hardest programming language?
What is c++ vb?
What is == in programming?
How can you quickly find the number of elements stored in a dynamic array?
What is ios in c++?
What is vector pair in c++?
Can you be bale to identify between straight- through and cross- over cable wiring? And in what case do you use straight- through and cross-over?
What is the syntax for a for loop?
What are vtable and vptr?
Write a Program for dynamically intialize a 2 dimentional array. Eg:5x20, accept strings and check for vowels and display the no.finally free the space allocated .
What are friend classes? What are advantages of using friend classes?
Define token in c++.