the last array array 3 is not giving me the desired output. i see no logic errors therefore i do not know why i am getting the wrong output.

#include<stdio.h>

    int arr1[5]={55,145,950,25,500};
    int arr2[5]={44,58,98,25,62};
    int arr3[5],array1,array2,array3;
    int i=0,j=0,k=0;

    for(i=0;i<5;i++){
        array1=arr1[i]*2;
        printf("array 1 doubled is %d . \n",array1);
        //i++;

}
for(j=0;j<5;j++){
    array2=arr2[j]+3;
        printf("Array 2 increased by 3 is %d \n",array2);
        //j++;
    }
    for(k=0; k<5; k++){
        arr3[k]=array1+array2;
        //printf("the reverse order after operations is %d",arr3[0]);
        //k++;
        printf("reverse order is %d\n",arr3[k]);

 }

}

array1 and array 2 are declared as int. This means that you are overwriting the values in them and the last loop is re-using the last value stored in them. Without a clear idea of the desired outcome it's hard to arrive at a solution.

In your third loop, you are assigning each element of arr3 with the sum of the last values of array1 and array2, which would be 1065. To get the array reversed, you need to reference an array subtracting the index from the end. e.g.

printf("The reversed array is: ");
for (i=0; i<5; ++i)
{
    array3 = arr1[5-i];
    printf("%i ", array3);
}
printf("\n");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.