0
Need help with arrays
write a program which accepts an integer and its size as arguments and replaces elements having odd values with thrice its value and even elements with twice its value. eg- if array of 5 contains 3,4,5,16,9 the output should be 9,8,15,32,27. I am a newbie. plz keep the code simple.
1 Answer
+ 13
for(int x=0; x<5; x++) {
int a=myArr[x]
if(a%2==0) a+=a;
else a*=3;
cout << a << endl;
}