Sort by

recency

|

830 Discussions

|

  • + 0 comments
    int num, *arr, i;
        scanf("%d", &num);
        arr = (int*) malloc(num * sizeof(int));
        for(i = 0; i < num; i++) {
            scanf("%d", arr + i);
        }
        /* Write the logic to reverse the array. */
        for(i = 0; i < (num/2); i++){
                arr[i]= arr[i] + arr[num-(i+1)];
                arr[num-(i+1)] = arr[i] - arr[num-(i+1)];
                arr[i] = arr[i] - arr[num-(i+1)];
        }
        for(i=0; i<num; i++)printf("%d ",arr[i]);
    
  • + 0 comments

    //reverversing without third variable

    for (int i=0; i

    arr[num-i-1]=arr[i]-arr[num-1-i];
    
    arr[i]=arr[i]-arr[num-1-i];
    }
    
  • + 0 comments

    include

    int main() { int size; scanf("%d", &size); int arr[size]; for (int i = 0; i < size; i++) { scanf("%d", &arr[i]); } for (int i = size - 1; i >= 0; i--) { printf("%d ", arr[i]); } return 0; }

  • + 0 comments

    include

    include

    int main() { int n,j,i; scanf("%d", &n); int arr[n]; int length=sizeof(arr)/sizeof(arr[0]); for(j=0;j

  • + 0 comments

    include

    include

    int main() { int num, arr, i; scanf("%d", &num); arr = (int) malloc(num * sizeof(int)); for(i = 0; i < num; i++) { scanf("%d", arr + i); } arr[i]=i+1;

    for(i = 0; i < num; i++)
        printf("%d ", *(arr + i));
    return 0;
    

    }