I need to find all of the powers of in my input but the code I created only shows one of them, i feel something's wrong in my looping? Anw, heres the code and the problem. Help would really be appreciated thanks.
#include <stdio.h>
int ree(int arr[], int n);
int main ()
{
int n, i;
printf("Enter the size: ");
scanf("%d",&n);
int arr[n];
printf("Enter the Elements: ");
for(i=0;i<n;i++)
{
scanf("%d",&arr[i]);
}
int max = ree(arr, n);
printf("Powers of 2 = %d",max);
return 0;
}
int ree(int arr[], int n)
{
int i, max;
for(i = 0; i < n; i++)
{
if(i % 2 == 0)
{
max = i;
}
}
return max;
}