I wrote a program to multiply any floating point number by any integer either positive or negative:
insert
Code:
int main()
{
int count, y, finish;
float x, z;
while(finish!=0)
{
printf("Enter base number\n");
scanf("%f", &x);
printf("Enter power number\n");
scanf("%d", &y);
if (y>0)
{
z=1;
for(count=1;count<=y;count++)
{
z=z*x;
}
}
else;
{
z=1;
for(count=-1;count>=y;count--)
{
z=z*x;
}
}
printf("Answer = %f\n", z);
printf("Enter 0 to quit\n");
scanf("%d", &finish);
}
}
Every time it prints the answer as 1.00000 and i dont know why