cs50 - Expression result unused — what's wrong with my C code? -


i making program runs "greedy" algorithm — 1 asks input value of change owed , returns minimum amount of coins required return change while using few coins possible. coins can used quarter, dime, nickel , penny. please take @ code , tell me how fix error being displayed.

#include <stdio.h> #include <cs50.h> #include <math.h>  int main(void) {     float change;     int counter;     counter = 0;          {         printf("please imput how change owed: ");         change = getfloat();     }     while (change<=0);      int centv;     {         centv = round(change*100);     }      int quarter, dime, nickel, penny;     quarter= 25;     dime= 10;     nickel= 5;     penny= 1;      {         while( centv>=quarter )             {                        (centv-25);                 counter++;               }          while( centv>=dime )               {                                 (centv-10);                 counter++;             }                 while( centv>=nickel )             {                             (centv-5);                 counter++;             }         while( centv>=penny)             {                 (centv-1);                 counter++;             }             if(centv == 0)             {                 printf("%i \n", counter);             }     } } 

the errors i'm getting lines (centv-25), (centv-10), (centv-5) , (cent-1).

the error message "expression result unused" of them. how fix this?

if trying change value of centv, need centv = centv - 25;

centv - 25 should replaced centv = centv - 25, , other lines.


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -