MENU
Question -

Write code for a function void EvenOdd (int T[], int C) in C+ + , to add 1 in all the odd values and 2 in all the even values of the array T.
Example : If the original content of the array T is

T[0] T[l] T[2] T[3] T[4]
35 12 16 69 26
The modified content will be:

T[0] T[l] T[2] T[3] T[4]
36 14 18 70 28



Answer -

 void EvenOdd (intT [] , int(C)
 {
 for (int i=0; i
 {
 if (T[i] %2==0)
 T [i] + = 2;
 else
 T[i] + = 1;
 }
 }

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
×