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


Please Help Members By Posting Answers For Below Questions

Describe new operator?

890


What do you mean by storage classes?

1195


What is late binding c++?

764


Is c++ the hardest programming language?

866


What is c++ vb?

880


What is == in programming?

824


How can you quickly find the number of elements stored in a dynamic array?

838


What is ios in c++?

958


What is vector pair in c++?

984


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?

780


What is the syntax for a for loop?

852


What are vtable and vptr?

916


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 .

942


What are friend classes? What are advantages of using friend classes?

878


Define token in c++.

939