Hi,
In Below code
Code:
#include <stdio.h>
int main()
{
int array[100], n, c, t, end;
scanf("%d", &n);//4 number iam giving as input
end = n - 1;//end=3
for (c = 0; c < n; c++) {
scanf("%d", &array[c]);//arr[0]=2,arr[1]=3,arr[2]=4,arr[3]=5
}
for (c = 0; c < n/2; c++)
{
t = array[c];
array[c] = array[end];
array[end] = t;
//so for loop
/*for(c=0;c<2;c++),it would be
t=arr[0] ==it would be t=2 as arr[0]=2
arr[0]=arr[3] ==it would be arr[0]=5
arr[3]=t ==it would be arr[3]=2
so now arr[0]=5
arr[3]=2
/*Now for second for loop
/*for(c=1;c<2;c++) it would be
t=arr[1] ==it would be t=3
arr[1]=arr[3]//iam stuck here ,whatz this arr[end] depicts whether it is arr[3]
value or arr[2] value */
}
printf("Reversed array elements are:\n");
for (c = 0; c < n; c++) {
printf("%d\n", array[c]);
}
getch();
return 0;
}
i got stuck in second for loop as in comment