Answer to Question #22173 in C++ for sushmita

Question #22173
Write a function in C++ which accepts an integer array and its size as argumentsand replaces elements having odd values with thrice its value and elementshaving even values with twice its value.Example: if any array of five elements initially contains the elements as3,4,5,16,9Then the function should rearrange the content of array as9,8,15,32,27
1
Expert's answer
2013-01-17T08:45:50-0500

void manipulate (int a[ ],int size)
{ for (i=0;i<size;i++)
{ if (a[i]%2= =1)
a[i]=a[i]*3;
else
a[i]=a[i]*2;
cout<<a[i]<<’,’;
}
}

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 the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS