There’s no one, right way to stylize code. But there are definitely a lot of wrong (or, at least, bad ways). Even so, CS50 does ask that you adhere to the conventions below so that we can reliably analyze your code’s style. Similarly do companies typically adopt their own, company-wide conventions for style.
By convention the maximum length of a line of code is 80 characters long in C, with that being historically grounded in standard-sized monitors on older computer terminals, which could display 24 lines vertically and 80 characters horizontally. Though modern technology has obsoleted the need to keep lines capped at 80 characters, it is still a guideline that should be considered a “soft stop,” and a line of 100 characters should really be the longest you write in C, else readers will generally need to scroll. If you need more than 100 characters, it may be time to rethink either your variable names or your overall design!
Why did I implement this block in this way?
there isn’t any space immediately after each ( or immediately before each ).
each case (including default) ends with a break.
As for your own functions, be sure to define them similiarly, with each curly brace on its own line and with the return type on the same line as the function’s name, just as we’ve done with main.
If you need more than three variables for iteration, it might be time to rethink your design!
the loop’s body (a comment in this case) is indented with 4 spaces.
Though it’s fine to use variables like i, j, and k for iteration, most of your variables should be more specifically named. If you’re summing some values, for instance, call your variable sum. If your variable’s name warrants two words (e.g., is_ready), put an underscore between them, a convention popular in C though less so in other languages.