62 570
Assignments Done
99%
Successfully Done
In June 2018

Answer to Question #73482 in C++ for mian

Question #73482
Initialize an integer array of size 10; pass it to a function ‘arrIncrement’ using a void pointer.
The function should increment all elements of the array by one. Then display the
updated array on screen. (use casting)
Expert's answer
/*
Initialize an integer array of size 10; pass it to a function ‘arrIncrement’ using a void pointer.
The function should increment all elements of the array by one.
*/


#include <iostream>


void arrIncrement(void * p){
int* a=(int*)p;
for(int i=0;i<10;i++)
(*(a+i))++;
}

int main(void)
{
int a[]={2,5,1,9,7,0,8,-2,55,9};

arrIncrement(a);

for(int i=0;i<10;i++)
std::cout<<*(a+i)<<" ";

std::cout<<std::endl;
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions