java foir loop code example
Example 1: Java for loop
int values[] = {1,2,3,4};
for(int i = 0; i < values.length; i++)
{
System.out.println(values[i]);
}
Example 2: math.pow in C# using loop
static float CalculatePower(float x, int y)
{
float temp;
if (y == 0)
return 1;
temp = CalculatePower(x, y / 2);
if (y % 2 == 0)
return temp * temp;
else
{
if (y > 0)
return x * temp * temp;
else
return (temp * temp) / x;
}
}