Assuming that arr is an array containing 100 elements I need to write the equivalent while loop that corresponds to the following for loop.
Code:
for ( i=0, s=0.0;i<100;s=s+arr[ i ], i++) ;
Here what I have done:
Code:
#include <stdio.h>
int main()
{
int s;
int i;
s = 0.0;
i = 0;
while ( i<100 ){
printf( "%d \n", i = i++ );
s = s+arr[i];
}
return 0;
}
But how do i declare the array?
Errors recieved :
xc.c(14) : error C2065: 'arr' : undeclared identifier
xc.c(14) : error C2109: subscript requires array or pointer type
I doubt that I have to use define SIZE.
Thanks