C PROGRAM TO ACCEPT N INTEGERS AND STORE THEM IN AN ARRAY | Indian Shout

You are here: » C PROGRAM TO ACCEPT N INTEGERS AND STORE THEM IN AN ARRAY

C PROGRAM TO ACCEPT N INTEGERS AND STORE THEM IN AN ARRAY


/* Program to accept N integer number and store them in an array AR.
* The odd elements in the AR are copied into OAR and other elements
* are copied into EAR. Display the contents of OAR and EAR */

#include <stdio.h>
void main()
{
long int ARR[10], OAR[10], EAR[10];
int i,j=0,k=0,n;

printf(“Enter the size of array AR\n”);
scanf(“%d”,&n);

printf(“Enter the elements of the array\n”);
for(i=0;i<n;i++)
{
scanf(“%ld”,&ARR[i]);
fflush(stdin);
}
/*Copy odd and even elemets into their respective arrays*/
for(i=0;i<n;i++)
{
if (ARR[i]%2 == 0)
{
EAR[j] = ARR[i];
j++;
}
else
{
OAR[k] = ARR[i];
k++;
}
}

printf(“The elements of OAR are\n”);
for(i=0;i<j;i++)
{
printf(“%ld\n”,OAR[i]);
}

printf(“The elements of EAR are\n”);
for(i=0;i<k;i++)
{
printf(“%ld\n”, EAR[i]);
}
}    /*End of main()*/
/*————————————-
Output
Enter the size of array AR
6
Enter the elements of the array
12
345
678
899
900
111
The elements of OAR are
345
899
111
The elements of EAR are
12
678
900
—————————————*/

Similar Posts:

 
 
Posted by 1 Response

Categories:PREPARATION MATERIALS;Tags: , , , , , , , , ,

Free Email Newsletter

Stay Updates with this Blog. Get Free email newsletter updates..

And then confirm your email subcription

   

One Comment to “C PROGRAM TO ACCEPT N INTEGERS AND STORE THEM IN AN ARRAY”

  1. prabharani says:

    i want code for sorting of charecters

Leave your comment here:

 
Search
Free Email Updates
Get All Latest Updates in Ur e-mail Inbox..

And then confirm your email subcription

Free SMS Alerts
Sponsored Links
Copy Protected by Chetans WP-Copyprotect.