0

Here is the code I submitted:

// include all needed Header files
#include <stdio.h>
#include <cs50.h>


int main(void) {

    // prompt user for Celsius value
    float celsius = get_float("C: ");

    // return Fahrenheit value
    printf("F: %.1f\n", ((celsius * 9) / 5) + 32);

}

However, I received only a 4/5 on style (and a 5/5 on correctness). Why is this? What styling changes should I make?

2
  • Did you run style50 on the source code? Apr 16 '19 at 12:04
  • Ah, no. I’ll do that. Thank you! Apr 16 '19 at 12:05
1

Recheck line number 6; the curly braces should be on their own line.

2
  • I don’t believe this to be good practice, though I did it anyway to get the points... Apr 16 '19 at 15:28
  • The reason it's considered to be good style is this. It lines up with the closing brace vertically so that it is clear which two are paired together. The same logic applies to all internal curly brace pairs too.
    – Cliff B
    Apr 16 '19 at 19:27

You must log in to answer this question.

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