|
-
Dec 26th, 2001, 06:34 AM
#1
Thread Starter
Hyperactive Member
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.
Last edited by iflash; Dec 26th, 2001 at 08:27 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|