#Powers of 2

2 messages · Page 1 of 1 (latest)

small loom
#

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;

}

next horizonBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.