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
boyakko [2]
2 years ago
14

Implement the function lastChars() that takes a list of strings as a parameter and prints to the screen the last character of ea

ch string, one per line. If the list provided as a parameter is empty, the function prints a message to that effect. If any of the strings are empty, they are skipped in the display. The information below shows how you would call the function lastChars() and what it would display for a couple of parameters:
Engineering
1 answer:
Liono4ka [1.6K]2 years ago
8 0

Answer:

The following program is in C++.

#include <bits/stdc++.h>

using namespace std;

void lastChars(string s)

{

   int l=s.length();

   if(l!=0)

   {

       cout<<"The last character of the string is: "<<s[l-1];

   }

}

int main() {

   string s;//declaring a string..

   getline(cin,s);//taking input of the string..

   lastChars(s);//calling the function..

return 0;

}

Input:-

Alex is going home

Output:-

The last character of the string is: e

Explanation:

In the function lastChars() there is one argument that is a string.I have declared a integer variable l that stores the length of the string.If the length of the string is not 0.Then printing the last character of the string.In the main function I have called the function lastChars() with the string s that is prompted from the user.

You might be interested in
The rate of energy transfer by work is called power. a)-True b)-False
Pie

Answer:

Yes the statement is true.

Explanation:

Power is defined as the rate at which energy is transferred by an object on account of work done.

Mathematically

Power=\frac{dE}{dt}

An object that does work loses it's energy while an object on which work is done gains energy.

Power is often dependent on the type of energy transfer thus we have Electrical Power, Mechanical Power depending on the type of energy involved in the system.

Concept of power is important since it gives us a measure of how fast energy can be derived to given to a system.

5 0
3 years ago
One reason the shuttle turns on its back after liftoff is to give the pilot a view of the horizon. Why might this be useful?
nordsb [41]
To look at your surroundings and see if there’s any tall mountains because they can effect air currents
5 0
2 years ago
Read 2 more answers
What major problems could you encounter in complex intersections?
Natali5045456 [20]

Types of Problems

Inappropriate intersection traffic control.

Inadequate visibility of the intersection or regulatory traffic control devices.

Inadequate intersection sight distance.

Inadequate guidance for motorists.

Excessive intersection conflicts within or near the intersection.

Vehicle conflicts with non-motorists.

3 0
2 years ago
You are a designer of a new processor. You have to choose between two possible implementations (called M1 and M2) of the same ar
Kaylis [27]

Answer:

A ) CPI : M1 = 2.4 , M2 = 2.65

B ) MIPS : M1 = 1083, M2 = 1056

C ) The machine that has a better performance based on MIPS is M1 and this is  by 27 million number of instructions per sec

Explanation:

A) The CPI for each machine

CPI = ( Total number of execution cycles ) / ( instruction counter executed )

For Machine 1 ( M1 )

we have to make some assumptions : number of instructions = 10

number of times A was executed = 4 , Number of times B was executed = 2.5 , number of times C was executed = 2.5, Number of times D was executed = 1. and this was based on the frequency given above

hence CPI for M1 =[ ( 1 * 4 ) + ( 3 * 2.5 ) + ( 3 * 2.5 ) + ( 5 * 1 ) ] / 10

       CPI  for M1 = 2.4

For Machine 2 ( M2 )

we have to make some assumptions : number of instructions = 10

number of times A was executed = 4 , Number of times B was executed = 2.  number of times C was executed = 1.5, Number of times D was executed = 2.5 times. and this was based on the frequency given above

Hence CPI  for M1 = [ ( 2 * 4 ) + ( 2 * 2 ) + ( 3 * 1.5 ) + ( 4 * 2.5 ) ] / 10

            CPI for M2 = 2.65

B ) Calculate the native MIPS  ratings for M1 and M2

MIPS = ( instruction counts ) / ( Execution time * 10^6 )

For M1

Assumptions : number of instructions executed = 10

                        each clock cycle = 0.3846 * 10^-9.      frequency = 2.6 Ghz

first we calculate the total execution time which is equal to :

= [ ( 1 * 4 ) + ( 3 * 2.5 ) + ( 3 * 2.5 ) + ( 5 * 1 ) ] * 0.3846 * 10 ^-9

= 9.2304 * 10 ^-9 secs

therefore the MIPS for M1

= 10 / ( 9.2304 * 10^-9 ) * 10^6  = 1083

                                         

For M2

Assumptions : number of instructions executed = 10

                        each clock cycle = 0.3846 * 10^-9.      frequency = 2.8 Ghz

first we calculate the total execution time which is equal to :

= [ (2*4) + (2*2) + (3 * 1.5 ) + ( 4 * 2.5 ) ] * 0.3846 * 10^-9 = 9.4631 * 10^-9 secs

therefor the MIPS for M2

= 10 / ( 9.4631*10^-9) * 10^6 = 1056

C ) The machine that has a better performance based on MIPS is M1 and this is by 27 million number of instructions per sec

8 0
2 years ago
These are the most widely used tools and most often abuse tool​
Mars2501 [29]
Where is the picture in this problem? How am I supposed to answer if I can’t see any footage taken from this problem.
4 0
2 years ago
Read 2 more answers
Other questions:
  • Technician A says a basic circuit problem can be caused by something in the circuit that increases voltage. Technician B says a
    8·1 answer
  • Which tool is used to pull the tapered shaft on a tie-rod end from its mating steering component?
    9·1 answer
  • Opposition to current flow, restricts or resists current flow
    15·1 answer
  • What is the uncertainty in position of an electron of an atom if there is t 2.0 x 10' msec uncertainty in its velocity? Use the
    12·1 answer
  • Under the normal sign convention, the distributed load on a beam is equal to the:_______A. The rate of change of the bending mom
    13·1 answer
  • A strong base (caustic or alkali) is added to oils to test for: b. entrained air a)- alkalinity b)- acidity c)- contamination. d
    11·1 answer
  • Has anyone lost faith in humanity ✌️
    7·1 answer
  • 1. In order for a team to accomplish its goal(s), it is NOT important for the team members to
    14·2 answers
  • Fig. 4 shows a simply-supported beam with supports A and B. The beam is subjected to three forces, 2000 N, 4000 N and 1500 N in
    5·1 answer
  • 3. Sitúese en la época de los faraones en Egipto. Usted es el encargado de construir una de esas fabulosas pirámides que fueron
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!