Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
56 lines (34 loc) · 758 Bytes

File metadata and controls

56 lines (34 loc) · 758 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
Program to Separate Even and Odd numbers in an array
Author : Krishna Teja G S
Repository : github.com/packetprep/coding-questions
Website : packetprep.com
*/
#include<stdio.h>
int main(){
int arr[] = {3,4,7,9,2,6,8};
int i=0,j=0,k=0;
int even[10]={0},odd[10]={0};
int n = sizeof(arr)/sizeof(int);
printf("Elements: \n");
for(i=0;i < n ;i++){
printf("%d ",arr[i]);
}
for(i=0;i < n ;i++){
if(arr[i]%2==0){
even[j]=arr[i];
j++;
}else{
odd[k]=arr[i];
k++;
}
}
//Print Even numbers
printf("\n\nEven numbers in the array are:\n");
for(i=0;i<j;i++)
printf("%d ",even[i]);
//Print Odd numbers
printf("\n\nOdd numbers in the array are:\n");
for(i=0;i<k;i++)
printf("%d ",odd[i]);
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.