Put Even and Odd Numbers of an Array in two Arrays - Wisdom Lighter

# Put Even and Odd Numbers of an Array in two Arrays C++ Here is source code of the C program to put even & odd elements of an array in 2 separate arrays. The program is successfully compiled and tested using Turbo C compiler in windows environment. The program output is also shown below.

1. `    /*`
2. `     * C Program to accept N integer number and store them in an array AR.`
3. `     * The odd elements in the AR are copied into OAR and other elements`
4. `     * are copied into EAR. Display the contents of OAR and EAR.`
5. `    */`
6. ` `
7. `    #include <stdio.h>`
8. `    void main()`
9. `    {`
10. ` `
11. `        long int ARR, OAR, EAR;`
12. `        int i, j = 0, k = 0, n;`
13. ` `
14. `        printf("Enter the size of array AR n");`
15. `        scanf("%d", &n);`
16. ` `
17. `        printf("Enter the elements of the array n");`
18. `        for (i = 0; i < n; i++)`
19. `        {`
20. `            scanf("%ld", &ARR[i]);`
21. `            fflush(stdin);`
22. `        }`
23. ` `
24. `        /*  Copy odd and even elements into their respective arrays */`
25. ` `
26. `        for (i = 0; i < n; i++)`
27. `        {`
28. `            if (ARR[i] % 2 == 0)`
29. `            {`
30. `                EAR[j] = ARR[i];`
31. `                j++;`
32. `            }`
33. `            else`
34. `            {`
35. `                OAR[k] = ARR[i];`
36. `                k++;`
37. `            }`
38. `        }`
39. ` `
40. `        printf("The elements of OAR are n");`
41. `        for (i = 0; i < j; i++)`
42. `        {`
43. `            printf("%ldn", OAR[i]);`
44. `        }`
45. ` `
46. `        printf("The elements of EAR are n");`
47. `        for (i = 0; i < k; i++)`
48. `        {`
49. `            printf("%ldn", EAR[i]);`
50. `        }`
51. ` `

# Output

Enter the size of array AR
6
Enter the elements of the array
34 56 78 90 12 39
The elements of OAR are 39
The elements of EAR are 34 56 78 90 12
{"ft_lang_label":"__label__en","ft_lang_prob":0.6037672,"math_prob":0.99257964,"size":972,"snap":"2019-43-2019-47","text_gpt3_token_len":329,"char_repetition_ratio":0.16322315,"word_repetition_ratio":0.115,"special_character_ratio":0.4238683,"punctuation_ratio":0.16371681,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9917015,"pos_list":[0,1,2,3,4],"im_url_duplicate_count":[null,1,null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-11-19T09:54:45Z\",\"WARC-Record-ID\":\"<urn:uuid:68b2f1ae-760e-4895-b836-8e6f779ade64>\",\"Content-Length\":\"208072\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:e8ee931a-a3bc-46ca-a7e3-582f87f0447a>\",\"WARC-Concurrent-To\":\"<urn:uuid:b7af7fe5-fc9a-4164-9a32-a19103a58d21>\",\"WARC-IP-Address\":\"172.217.7.147\",\"WARC-Target-URI\":\"https://www.wisdomlighter.com/2018/05/c-program-to-put-even-odd-elements-of.html\",\"WARC-Payload-Digest\":\"sha1:L62LGGB3N3JVC2ZZXF7SIPHNVEVX5JOK\",\"WARC-Block-Digest\":\"sha1:23CLKIT3DHAJDP524U6VDREKNOQUNXMA\",\"WARC-Identified-Payload-Type\":\"application/xhtml+xml\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-47/CC-MAIN-2019-47_segments_1573496670135.29_warc_CC-MAIN-20191119093744-20191119121744-00417.warc.gz\"}"}