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
marishachu [46]
1 year ago
4

Complete the function FindLastIndex() that takes one string parameter and one character parameter. The function returns the inde

x of the last character in the string that is not equal to the character parameter. If no such character is found, the function returns -1.
Ex: If the input is tbbdn b, then the output is:
4
#include
using namespace std;
int FindLastIndex(string inputString, char x) {
/* Your code goes here */
}
int main() {
string inString;
char x;
int result;
cin >> inString;
cin >> x;
result = FindLastIndex(inString, x);
cout << result << endl;
return 0;
}
Computers and Technology
1 answer:
vlada-n [284]1 year ago
5 0

Using the codes in computational language in C++ it is possible to write a code that complete the function FindLastIndex() that takes one string parameter and one character parameter.

<h3>Writting the code:</h3>

<em>#include <iostream></em>

<em>using namespace std;</em>

<em />

<em>int </em><em>FindLastIndex</em><em>(string inputString, char x)</em>

<em>{</em>

<em>  // running a for loop that iterates the inputString from the last index and comes down to the 0th index. We are iterating from the last index because we want to find the last character such that it is not equal to x. So iterating the string from last makes more sense because we will find the value faster as compared to searching from the front to get that last value.</em>

<em>  for (int i = </em><em>inputString</em><em>.length() - 1; i >= 0; i--) {</em>

<em>    // if current character not equals the character x then return the index</em>

<em>    if (inputString[i] != x) {</em>

<em>      return i;</em>

<em>    }</em>

<em>  }</em>

<em />

<em />

<em>  // if the above loop didn't return an index, then all the characters are same in the string, hence return -1</em>

<em>  return -1;</em>

<em>}</em>

<em />

<em>int main()</em>

<em>{</em>

<em>  string </em><em>inString</em><em>;</em>

<em>  char x;</em>

<em>  int result;</em>

<em />

<em>  cin >> inString;</em>

<em>  cin >> x;</em>

<em />

<em>  result = </em><em>FindLastIndex</em><em>(inString, x);</em>

<em />

<em>  cout << result << endl;</em>

<em />

<em>  return 0;</em>

See more about C++ at brainly.com/question/29225072

#SPJ1

You might be interested in
A digital forensic analyst examines the original digital source (e.g. computer, flash drive, backup tape) suspected of being inv
mel-nik [20]

Answer: True

Explanation:

Digital forensic analysts are the people who examine digital devices such as cameras, mobile phones and computers in order to get evidence of crime.

The evidence gotten by them can then be used to provide support to criminal investigations and can also be given to the intelligence agencies. Their function is to get back and safeguard the digital data which are related to cybercrime investigations as well as criminal investigations.

6 0
3 years ago
Which of the following activities is not permissible for IT professionals while on the job? Check all of the boxes that apply.
Julli [10]

Answer:

sending coworkers an e-mail joke containing suggestive humor

Explanation:

i think that is the not permissible

7 0
2 years ago
Read 2 more answers
What invention during the renaissance period enabled people to purchase music for their own personal use?
bogdanovich [222]
Printing press_____________________________________________________                                                        
6 0
3 years ago
Read 2 more answers
I WILL UPVOTE!!!!!!!
vekshin1
Any of these can cause a disorder of this degree
6 0
3 years ago
Drag the system component on the left to the device or program that fits with the system component.
Strike441 [17]

Answer:

A. Back up software - Utility software

B. Printer - Device drivers

C. Camera - Firmware

D. Television - Firmware

E. Games console - Firmware

F. Antivirus software - Utility software

G. Disk Cleaner - Utility software

H. Video Card - Device drivers

Explanation:

Computer system components are the physical or hardware and software parts of the device. It is a combination of system software like utility software, device drivers and firmware, application software, and the hardware components and kernel.

4 0
3 years ago
Other questions:
  • Which step of creating a financial budget involves listing the payroll, rental, and utility costs?
    10·2 answers
  • A Chief Information Officer (CIO) recently saw on the news that a significant security flaws exists with a specific version of a
    5·1 answer
  • Using the _______ list, you can select the number of photos that will appear on each slide.
    14·1 answer
  • Angelika just submitted her product for the first time, and she had 2 errors, 3 warnings, and 5 notifications. What does she nee
    7·2 answers
  • Write a program that prompt the user to enter the coordinate of two points (x1, y1) and (x2,y2), and displays the slope of the l
    10·1 answer
  • A systems administrator is designing a directory architecture to support Linux servers using Lightweight Directory Access Protoc
    11·1 answer
  • The writers that most likely influenced our Founding Fathers were _____. Select all that apply. Swift and Bacon Marlowe and Kant
    14·2 answers
  • Jacob develops a new app that will display the current weather centered on a user's location and notify the user in the case of
    7·2 answers
  • Who is willam afton from five nights at freddy
    13·2 answers
  • List three natural defects of wood<br>​
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!