Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2 2 . Reflect on Exercise 4 What we had you do with first _ vowel may seem weird. At first we had you return

22. Reflect on Exercise 4
What we had you do with first_vowel may seem weird. At first we had you return the length of the string if no vowel was found. Then we had you change it to -1 at the very end. Why do it this way? Why not make a failed find return -1 in the very beginning, especially since this is how the function find_str in introcs works?
You could have done it this way. You could have written your code as follows:
result =-1 # Nothing found yet
if something
do something
...
return result
skipping over each if statement if the vowel is not there.
But you would have to change your if statements a lot to account for this. And depending on your comfort with boolean expressions, you might find it harder to do it this way. What do you think?
Do you think our approach was easier than starting with -1? Why or why not?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DB2 Universal Database V7.1 Application Development Certification Guide

Authors: Steve Sanyal, David Martineau, Kevin Gashyna, Michael Kyprianou

1st Edition

0130913677, 978-0130913678

More Books

Students also viewed these Databases questions

Question

Have I incorporated my research into my outline effectively?

Answered: 1 week ago