1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Schach [20]
3 years ago
15

Write a function called ReverseLetters that takes an input phrase consisting of a single word and reverses the sequence of lette

rs between the first letter and last letter. The input phrase could be a character vector of any length.
Computers and Technology
1 answer:
ad-work [718]3 years ago
4 0

Answer:

# The function reverseLetter is defined

def reverseLetter(received_word):

   # The first letter of the word is assigned to a variable using index 0

   firstLetter = received_word[0]

   # The last letter of the word is assigned to a variable using index of

   # string length - 1

   lastLetter = received_word[len(received_word) - 1]

   # reverse letters in between first and last letter is defined as

  # empty string

   reverseBetween = ""

   # A counter is defined to control the loop during the reversal

   # counter value is 2 from the length of the received string

   # The 2 is for the first and last letter remove

   counter = len(received_word) - 2

   # The while loop start

   while counter >= 1:

       # The reverseBetween string is concatenated with corresponding

      # index of received word

       # The index is from high to low since the process is string reversal

       reverseBetween += received_word[counter]

       # The value of counter is decremented

       counter -= 1

   # The reversed string is displayed with no separator

   print(firstLetter, reverseBetween, lastLetter, sep="")    

Explanation:

The code is well commented.

reverseLetter("come") will output cmoe

reverseLetter("welcome") will output wmoclee

reverseLetter("brainly") will output blniary

You might be interested in
Advantages of ASCII over EBDCDIC​
KiRa [710]
<h3>Efficiency. Moreover, the same character in ASCII requires 7 bits, but EBCDIC required 8 bits. Therefore, ASCII is more efficient than EBCDIC.</h3>

7 0
3 years ago
Which of these are variables in an organization? Choose three.
Rzqust [24]

Answer:

Example of organizational variables are codes of ethics, ethical climate, organizational size, top management, organizational structure and organization culture.

Explanation:

Organizational variables can be defined as characteristics of a decision that influences the decision-making process and its outcome. This organizational variables also influence how an individual makes decisions.

Example of organizational variables are codes of ethics, ethical climate, organizational size, top management, organizational structure and organization culture.

6 0
2 years ago
#include using namespace std; int main( ) { const int NUM_ROWS = 2; const int NUM_COLS = 2; int milesTracker[NUM_ROWS][NUM_COLS]
VARVARA [1.3K]

Answer:

#include <iostream>

using namespace std;

int main()

{

   const int NUM_ROWS = 2;

   const int NUM_COLS = 2;

   int milesTracker[NUM_ROWS][NUM_COLS];

   int i = 0;

   int j = 0;

   int maxMiles = -99; // Assign with first element in milesTracker before loop

   int minMiles = -99; // Assign with first element in milesTracker before loop

   milesTracker[0][0] = -10;

   milesTracker[0][1] = 20;

   milesTracker[1][0] = 30;

   milesTracker[1][1] = 40;

   

   maxMiles = milesTracker[0][0];

   minMiles = milesTracker[0][0];

   

   for (i = 0; i < NUM_ROWS; i++){

       for (j = 0; j < NUM_COLS; j++){

           if (milesTracker[i][j] > maxMiles){

               maxMiles = milesTracker[i][j];

           }

           if (milesTracker[i][j] < minMiles){

               minMiles = milesTracker[i][j];

           }

       }

   }

   

   cout << "Min: " << minMiles << endl;

   cout << "Max: " << maxMiles << endl;

   return 0;

}

Explanation:

It seems you want to find the min and max value in the array. Let me go through what I added to your code.

Set the maxMiles and minMiles as the first element in milesTracker

Create a nested for loop that iterates through the milesTracker. Inside the loop, check if an element is greater than maxMiles, set it as maxMiles. If an element is smaller than minMiles, set it as minMiles.

When the loop is done, print the minMiles and maxMiles

5 0
3 years ago
Tristan has successfully deleted the blank row. The next thing he wants to do is to increase the length of the first column. A 2
Sonja [21]

Answer:

B

Explanation:

;)

4 0
3 years ago
Read 2 more answers
Describe an unethical situation you might encounter at school. Discuss how you would handle the situation and explain why you wo
natali 33 [55]
If someone is threatening to shoot up the school, you would report it to the principal. You would handle it that way so the child can get arrested and nobody will be harmed.
5 0
3 years ago
Read 2 more answers
Other questions:
  • To gain one pound of fat, how many extra calories would you need to consume?
    12·1 answer
  • What will happen with communication methods in five years?
    8·1 answer
  • The ____ file permission category in unix/linux systems typically entails all permissions and is designated by the letter u.
    7·1 answer
  • If you want an app to reach the largest possible audience, which two platforms should you use?
    7·1 answer
  • You support Richman Investments, a brokerage firm that employs 20 brokers. Each broker has his own client computer, and the firm
    15·1 answer
  • 1.Write the Qbasic program to find sum of any 10 different numbers.
    12·1 answer
  • Which of these is NOT one of the three parts to the event-handling mechanism in Java?
    10·1 answer
  • Difrent between computer and computer system​
    9·1 answer
  • Kathleen has written this paragraph:
    7·2 answers
  • Do small companies need computers? why?<br>​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!