Generation

generate functionFri, 11 Nov 2022

Odd and even number in ascending order

++ int main(){ int a[] = {6, 2, 3, 4, 7, 1, 5, 8}; int len = sizeof(a)/sizeof(a[0]); int odds[100]; int evens[100]; int i; int j = 0; int k = 0; for(i = 0; i < len; i++){ if(a[i] % 2 == 0){ evens[j] = a[i]; j++; }else{ odds[k] = a[i]; k++; } } for(i = 0; i < j; i++){ for(int n = 0; n < j; n++){ if(evens[i] < evens[n]){ int temp = evens[i]; evens[i] = evens[n]; evens[n] = temp; } } } for(i = 0; i < k;

Questions about programming?Chat with your personal AI assistant