MENU
Question -

Write a function Alternate (int A[] [3], int N, int M) in C + + to display all alternate elements from two-dimensional array A(starting from A[0][0]).
For example:
If the array is containing :
23 54 76
37 19 28
62 13 19
The output will be
23 76 19 62 19



Answer -

void Alternative (int A[] [3], intN, int M)
 {
 int T=0 ; I
 for (int J=0 ; J {
 if (T%2 = 0)
 COUt << A[I] [J]<<" " ;
 T++ ;
 }
 }
 OR
 void Alternative (int A[] [3] , intN, int M)
 {
 int *P=&A [0] [0] ;
 for (int I = 0; I
 {
 Cout<<*p<<" " ;
 { I+=2 ;
 }
 }
OR
Any other equivalent correct answer acceptable

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
×