Generation

generate functionMon, 02 Jan 2023

how to reverse array?

void reverse(int a[], int n) { for(int i = 0; i < n / 2; i++) { int temp = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = temp; } } int a[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; reverse(a, 10); for(int i = 0; i < 10; i++) { printf("%d ", a[i]); }

Want to kickstart your project?Use the new AI Studio to create your code