.


:




:

































 

 

 

 


2. , .




/*change.c*/main(){int amount, twenties, tens, fives, ones, r20, r10;printf(" : ");scanf("%d", &amount);twenties = amount / 20;r20 = amount % 20; /*r20 - */tens = r20 / 10;r10 = r20 % 10; /*r10 - */fives = r10 / 5;ones = r10 % 5;putchar('\n');printf(" %d \ , :", amount);printf("%d () 20 ", twenties);printf("%d () 10 ", tens);printf("%d () 5 ", fives);printf("%d () 1 ", ones);}

, , 57, :

57 , :2 () 20 1 () 10 1 () 5 2 () 1

. 2 . twenties = amount/20. amount, twenties int, . , 20 amount. , . twenties , , 20 , .

 


. 2. ,

, , 20 , : ? , . 20 , , 10 . . , %. r20 = amount % 20 r20 , amount 20. , , 20, . 20 40 , 17 . 17 tens.

, twenties, tens fives. ones 5.

, . , float, , , float. :

main(){floatcost, shipping, total;cost = 56.09;shipping = 4.98;total = cost + shipping;printf(" %.2f \", total);}

, , :

61.07

. . :

main(){int total;float cost, shipping;cost = 56.09;shipping = 4.98;total = cost + shipping;printf(" %d ", total);}

float (cost shipping), total. , 61.07, total , . %d 61.


.3. ,

, , (.3). , 60 (56+4).

, float:

main(){int cost, shipping;float total;cost = 56;shipping = 4;total = cost + shipping;printf(" %.2f \ ", total);}

, total %f, . , , 60.00.

float int , . :

main(){intshipping;floattotal, cost;cost = 56.09;shipping = 4;total = cost + shipping;printf(" \%.2f ", total);}

int float, foat (60.09).

. : , , float, , , () . .4 , . float. , .


. 4.

, . . :

main() { intcount; count = 5; printf(" %d", count+19); }

:

24

printf() count+19. () . %d.

. , count+19, count - 5. , , .

, , :

printf("%d", count+number);printf("%d", 16-4);printf(%f", amount*TAX_RATE);

, . , , . :

main() { floatcost, shipping; printf(" : "); scanf("%f", &cost); printf(" : "); scanf("%f", &shipping); printf(" %f", cost+shipping); }

printf(" %f", cost+shipping);

, :

total = cost + shipping;/*total float*/printf(" %f", total);

. , , , . , printf(). , , , , , cost+shipping.

, , . , .

, - , - . , .





:


: 2017-03-12; !; : 324 |


:

:

, ,
==> ...

1504 - | 1426 -


© 2015-2024 lektsii.org - -

: 0.009 .