Q:

Predict the output of following C++ program

0

 

//Problems for pointers in c++

#include

using namespace std;

#include

const int s=6;

int * add(){

int *p1=new int[s];

int *p2=new int[s];

int *p=new int[s];

for(int i=0;i<s;i++){

*(p1+i)=rand()%11;

*(p2+i)=rand()%21;

*(p+i)=*(p1+i)+*(p2+i);

}

return p;

}

int main()

{

int *vp;

vp=add();

for(int i=0;i<s;i++){

cout<<*(vp+i)<<" ";

cout<<endl;

}

}

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

10

25

11

9

13

27

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now