Exerxise 2/ lab sheet 7 (arrays)

PHOTO EMBED

Mon Dec 12 2022 17:03:51 GMT+0000 (Coordinated Universal Time)

Saved by @Mohamedshariif

#include <stdio.h>
#include <stdlib.h>

//EXERCİSE 2
//Write a modification of first exercise such that while printing the contents of the array the even numbers will be printed first line and odd numbers will be printed on the second line.

//even number are = .....
//odd number are = ......
int arr[10];
    int i;
    for(i=0;i<=9;i++)
    {
        printf("Element %d: ",i+1);
        scanf("%d",&arr[i]);
    }

    printf("Even numbers: ");
    for(i=0;i<=9;i++)
    {
        if(arr[i]%2==0)
            printf("%d ",arr[i]);
    }

    printf("\nOdd numbers: ");
    for(i=0;i<=9;i++)
    {
        if(arr[i]%2==1)
            printf("%d ",arr[i]);
    }
return 0;
content_copyCOPY