C Language - Array Reversal
#include <stdio.h>
#include <conio.h>
int func (int array1[])
{
int temp;
int i;
for (i=0; i<7/2; i++)
{
temp = array1[i];
array1 [i] = array1 [6-i];
array1 [6-i] = temp;
}
}
int main()
{
int array [] = {12, 33, 43, 42, 43, 45, 65};
func (array);
int i;
for (i=0; i<7; i++)
{
printf ("The reversed value at %d is %d \n", i, array[i]);
}
}
// ScreenShots:
Comments
Post a Comment