QP School

Full Version: Writing clean and maintainable code in C
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Writing clean and well-organized code enhances readability and maintainability.

// Bad coding style
int f(int x){int i=0;for(;i<x;++i)printf("%d ",i);return i;}

// Improved coding style
int print_numbers(int limit) {
    for (int i = 0; i < limit; ++i) {
        printf("%d ", i);
    }
    return limit;
}