Question : arr[1, 2, 3, 4, 5, 6, 7] ko arr[4, 5, 6, 7, 1, 2, 3] banana hai .
#include<stdio.h>
void reverse(int* arr) {
int frst = 0;
int temp;
int i;
int j;
while(frst != 3) {
temp = arr[0];
for(i = 1; i<=6; i++) {
arr[i - 1] = arr[i];
}
arr[6] = temp;
frst++;
}
for( j = 0; j<=6; j++) {
printf("%d", arr[j]);
}
}
int main() {
int arr[7] = {1, 2, 3, 4, 5, 6, 7};
reverse(arr);
return 0;
}
//4567 123
No comments:
Post a Comment