Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 6 : Extracting the Middle ( Reference: Textbook Chapter 3 Worked Example 3 . 1 ) ( for coamination of the problem. save Companice

Exercise 6: Extracting the Middle (Reference: Textbook Chapter 3 Worked Example 3.1)
(for coamination of the problem. save Companice Site)
Your task is to extract a string comtaining the middle character from a given string ser For example, if the string is "crate", the result is the string "a". However, if the string has an even number of letters, extract the midlle rwo charactes If the string is "crases", the result is "at"
Step 1 Decide on the branching condition
We aced to tuke different actions for strings of codd and cuen length.
Derefore, the condizion is 1s the lingth of the srring odd?
In lava, you use the remainder of division by 2 in find out utether a value is even of odd Then ife lest becomes strjengthi %2-1?
image text in transcribed

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions