Ask your own question, for FREE!
edX CS50x Intro to CS I 11 Online
OpenStudy (unklerhaukus):

.c code

OpenStudy (unklerhaukus):

This is one of my first programs in c can it be simplified? improved? is there someway to get the correct and incorrect paths to be nearer to each other in the code?

OpenStudy (unklerhaukus):

OpenStudy (e.mccormick):

To be honest, there is generally going to be better input verification. This would not simply things, but prevents issues caused by input that is designed to be harmful. Also, a lot of what makes C, and many other languages, more powerful is the use of functions or sub routines. As you go on, you will learn about those and how they can make programs more flexible and efficient.

OpenStudy (anonymous):

There is one way you can really simplify the code. Change ``` if ( condition ) { print( correct answer ); remaining program } else { print( wrong answer ); } ``` To ``` if ( condition ) { print( correct answer ); } else { print( wrong answer ); return 0; } remaining program ``` This will prevent nesting and make the flow or your program much more linear. Another thing you should do is implement functions.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!