C program to separate odd and even number from an array - My CS Tutorial - My CS Tutorial

Breaking

Programming languages full tutorial and programs, exam papers, visual basic( Vb.net ), information of new technologies and more....

Monday, February 3, 2020

C program to separate odd and even number from an array - My CS Tutorial

C program to separate even and odd numbers in array. C program to put even and odd elements of an array and separate these elements or numbers from an array.

In this tutorial we will discuss or read how to write a simple c language code to separate even and odd numbers from an array.

In the first we will enter the range of an array then we will enter the integers according to range.

After it compiler will check and execute the conditions and separate even and odd numbers.

Compiler will print the all numbers in two parts.
In the first part all even numbers are available. In the second part all odd numbers.


PROGRAM CODE


#include<stdio.h>
#include<conio.h>
void main()
{
int x,size;
int array[50];
clrscr();

printf("\n ENTER THE SIZE OF THIS ARRAY:\n ");
scanf("%d",&size);

printf("\n ENTER THE INTEGERS TO SEPARATE EVEN AND ODD:\n ");

for(x=0;x<size;x++)
{
    scanf("%d",&array[x]);
}

printf("\n EVEN NUMBERS THAT ARE AVAILABEL IN THIS ARRAY ARE:\n ");

for(x=0;x<size;x++)
{
    if(array[x]>=0)
    {
        if(array[x]%2==0)
        {
            printf("%d\n ",array[x]);
        }
    }
}

printf("\n ODD NUMBERS THAT ARE AVAILABEL IN THIS ARRAY ARE:\n ");

for(x=0;x<size;x++)
{
    if(array[x]>=0)
    {
        if(array[x]%2==1)
        {
            printf("%d\n ",array[x]);
        }
    }
}

getch();
}


OUTPUT:





Please share this post and blog link with your friends.For more programs use this blog.
If you have any problem, please comment in comment box, subscribe this blog for notifications of new post on your email and follow this blog.If you have any method of this program or want to give any suggestion send email on hc78326@gmail.com

Created by-- HARSH CHAUHAN

1 comment:

  1. I read your comment, I am ready to share your link on my site, but will you give me money in return and if so how many? Reply soon.

    ReplyDelete