Wednesday, 21 September 2016

Q. Write a program to make three array name mArry, even & odd move array value in even & odd array respect to this type ?

event odd sepration program output


/* #############################
      Girfa Student Help
      Event Odd Sepration Program
      for more programs visit : http://girfahelp.blogspot.in/2012/09/some-program-of-c-language.html
   ##############################
*/
#include<stdio.h>
#include<conio.h>
#define MAX 5
void main()
{
      int even[MAX*2],odd[MAX*2],ar[MAX],i,oddindex,evenindex;
      clrscr();
      for(i=0;i<MAX;i++)
      {

            printf("Enter Number %d >> ",i+1);
            scanf("%d",&ar[i]);
      }
      /* Sepration of event and odd number */
      for(i=0,oddindex=0,evenindex=0;i<MAX;i++)
      {
            if(ar[i]%2==0)
                  even[evenindex++]=ar[i];
            else
                  odd[oddindex++]=ar[i];
      }
      clrscr();
      /* Prinitng Main Array */
      printf("\n\nMain Array\n");
      for(i=0;i<MAX;i++)
            printf("\t%d",ar[i]);
      printf("\n\nEvent Array\n");
      /* Printing Even */
      for(i=0;i<evenindex;i++)
            printf("\t%d",even[i]);
      printf("\n\nOdd Array\n");
      /* Printing Odd */
      for(i=0;i<oddindex;i++)
            printf("\t%d",odd[i]);
      getch();