0

I have a problem with passing check50 with my greedy. As in title it gives the expected output, not a prompt for input error for every line. Thanks in advance!

#include <stdio.h>
#include <cs50.h>
#include <math.h>


int main(void)
{
int i;
    do{
float change = GetFloat();
i= round(change*100);
}while(i<=0);


int h=0;

do{

//0.25
if(i >= 25){
i=i-25;
}

//0.10
else if(i>= 10 && i <25){
i=i-10;
}

//0.05
else if(i>4&&i<10){
i=i-5;
}

//0.01
else{
i=i-1;
}

    h++;

    }while(i>0);

printf("%d\n", h);
return 0;
}

1 Answer 1

1

The specification is very specific as to its requirements. One of the first things your program must have is a prompt for user input, and to reprompt with an error when the user enters input beyond the scope. Run the staff's implementation a few times to get an idea what your program must do. Keep in mind these psets are automatically graded by a grading software so the outputs must meet tight specifications in order to be graded correctly.

1
  • :) Thanks! It was just the case of adding printf command!
    – Krymu
    Feb 9, 2015 at 9:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .