Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

This is a mq question on code quotient . I have tried [3 0 5 2 7] ,[2 1 4 3 6],[1 2 3 4 5]

void func(int a[5]) {
    int i; 
    for(int i=0;i<5;i++) { 
        if(i%2 == 0) a[i]++; 
        else a[i]-- 
    }
}

What would be the contents of array a after executing this function, if before passing a is as below:
1.)2 1 4 3 6

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

What would be the contents of array a after executing this function

From your given code snippet, we can infer that even numbers in the array will be incremented by 1 and odd numbers would be decremented by 1. So the answer is that the contents of the array would be:

3 0 5 2 7 

Check out the output of the program here for confirmation.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading