Hi,
Yes you should definitely use functions. There is a convention that functions should be less than 40 LOC, including main().
main()
returns an
int
by the way, so it should be
int main() {
While you are at it, you could get rid of the
goto
, use loops instead. This is not a hard and fast rule for everyone, but it is for beginners :+)
Also, this :
139 140 141 142 143 144
|
if (pick4=="Yes"||"yes"||"YES"){
goto start3;
}
else if (pick4=="No"||"NO"||"no"){
goto end1;
}
|
If you restrict the input to y or n, the logic is much simpler. One can use
toupper
or
tolower
to get a consistent case.
If you were to continue using this, then it would have to look like this:
if (pick4=="Yes" || pick4 == "yes" || pick4== "YES")
But you haven't accounted for every combination, so that is why I recommend using a single char as input.
Good Luck ! :+)
Edit:
I try to avoid do loops - it often means that end conditions are tested twice, and they can be error prone. Were you aware that all 3 types of loops can be converted to one of the other types. So I prefer
while
loops when the exact number of iterations isn't known (some condition instead), and
for
loops when the number of iterations is known.
Just because a loop must be executed once,
doesn't necessarily mean that it
has to be a do loop.