1 Attachment(s)
Caught in a loop for some reason...
Hi, i am new to C and when i tested my little program there comes an infinite loooooop. I searched for bugs but couldn't find any, pls help out. Source code is here:
----------------------------------------------------------------------------
/* Calculates total earnings of salesman per week. */
#include <stdio.h>
int main()
{
float sales, commission;
int retainer = 200;
printf( "Enter sales in dollars (-1 to end): " );
scanf( "%.2f", &sales );
while ( sales != -1 ) {
commission = sales * 9 / 100;
printf( "\nSalary is: %.2f\n", commission + retainer );
printf( "Enter sales in dollars (-1 to end): " );
scanf( "%.2f", &sales );
}
return 0;
}
-----------------------------------------------------------------------------
The output of the program on my screen is attached in a .jpg file. Pls read and thnx in advance. Just pls find out whats wrong with this piece of code.