>hi here is the solution for your problem.
Wonderful, yet another helpful bozo who's willing to teach beginners to be ignorant and rely on others to do their work for them.
>run the above code and get the disired result
Maybe, but then again, maybe not. Your entire program is undefined, and even if it weren't, it's littered with poor practices. I suggest you learn C before trying to teach it. Here are a few of the problems:
>#include "stdio.h"
It's conventional to use angle brackets for standard library headers and double quotes for everything else. When you use double quotes for standard headers, it suggests that you haven't used C long enough to know how code is expected to look. Also, most implementations search different locations first depending on whether <> or "" is used. By using "stdio.h", you may be forcing the implementation to unsuccessfully search a bunch of places before actually finding stdio.h. On the other hand, <> is more likely to search the correct path first.
>main()
This is correct:
int main ( void )
>float
There's no reason to use float. In fact, float may beless efficient than double, which is the default for floating-point constants. If you really think you're smart and float is the best choice, append f or F onto the end of every floating-point constant to be strictly correct.
>for(customers=1;customers<= NUM_CUSTOMERS ; ustomers++)
The only excuse for this is sheer stupidity. Aside from the obvious syntax error of using "ustomers", starting a loop at 1 rather than 0 and using <= instead of < defeats the concept of asymmetric bounds to make correctness checking simple and it encourages fencepost errors.
>scanf("%d",&num_hours);
I don't care how inexperienced someone is, you always set a good example by testing input functions for errors and end-of-file. There's no excuse to use a bare scanf, and the correct usage is something like this:
if ( scanf ( "%d", &num_hours ) != 1 ) {
/* Handle error or EOF */
}
>if(num_hours<=3)
"Up to" means "up to, but not including". So you're actually charging the minimum for four hours rather than three.
>}// end of main.
This is where the undefined behavior is. You say you're going to return int, but you don't return anything.
On top of all of that, ignoring poor formatting, you "solved the problem" but failed to meet most of the requirements. So not only did you break the rules by doing the OP's homework, you did it with a very bad solution.