while loop in C programing -
Type a program that contains a loop
while (scanf ("% 1f" loop A 17% federal blocking tax and 3% state stopping tax in the body and == 1) {...}
Print with these prices related salary, pay all the salaries and taxes
My current code:
float pay, federal_tax, state_taxa, pay_yah_ tax, Salary_su M, tax_sum, salary_after_tax_sum; printf ("enter pay: $"); while (scanned ("% lf", & amp; salary) == 1) {salary_sum = salary; federal_tax = pay * (.17); state_takz Salary_after_tax = Salary_after_tax_sum = salary_after_tax; Printf ("salary before salary =% lf", salary); Printf ("federal tax =% lf", Federal_tax); printf ("state tax =% lf", state_taxa); printf ("tax after pay =% lf \ n", salary_after_tax) break; } Printf ("Total salary before tax =% lf", salary_sum); Printf ("total tax =% lf", tax_sm); Printf ("Total salary after tax =% lf \ n", salary_after_tax_sum); System ("pause"); Return 0; }
For any reason this does not work, any help would be appreciated.
your scanf
specification % is Lf
( Your problem statement, % 1f
instead, is it deliberately?) And yet you are stored in float
my scanf (3)
Say % lf
specifies a double
.
Incidentally, float
is expected to have much less precision than many programmers, using only about seven digits, hence the use of double
For a good idea.
Comments
Post a Comment