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
DaniilM [7]
2 years ago
9

Complete the function to replace any period by an exclamation point. Ex: "Hello. I'm Miley. Nice to meet you." becomes:

Computers and Technology
1 answer:
vodomira [7]2 years ago
6 0

Answer:

Here is the complete function:

void MakeSentenceExcited(char* sentenceText) {  // function that takes the text as parameter and replaces any period by an exclamation point in that text

int size = strlen(sentenceText);  //returns the length of sentenceText string and assigns it to size variable

char * ptr;  // character type pointer ptr

ptr = sentenceText;  // ptr points to the sentenceText string

for (int i=0; i<size; i++){  //iterates through the sentenceText string using i as an index

    if (sentenceText[i]=='.'){  // if the character at i-th index of sentenceText is a period

        sentenceText[i]='!'; } } } //places exclamation mark when it finds a period at i-th index of sentenceText

Explanation:

The program works as follows:

Suppose we have the string:

sentenceText = "Hello. I'm Miley. Nice to meet you."

The MakeSentenceExcited method takes this sentenceText as parameter

int size = strlen(sentenceText) this returns the length of sentenceText

The size of sentenceText is 35 as this string contains 35 characters

size =  35

Then a pointer ptr is declared which is set to point to sentenceText

for (int i=0; i<size; i++) loop works as follows:    

1st iteration:

i=0

i<size is true because i=0 and size = 35 so 0<35

So the body of loop executes:

 if (sentenceText[i]=='.') statement checks :

if (sentenceText[0]=='.')

The first element of sentenceText is H

H is not a period sign so the statement inside if statement does not execute and value of i increments to 1. Now i = 1

2nd iteration:

i=1

i<size is true because i=1 and size = 35 so 1<35

So the body of loop executes:

 if (sentenceText[i]=='.') statement checks :

if (sentenceText[1]=='.')

This is the second element of sentenceText i.e. e

e is not a period sign so the statement inside if statement does not execute and value of i increments to 1. Now i = 2

So at each iteration the if condition checks if the character at i-th index of string sentenceText is a period.

Now lets see a case where the element at i-th index is a period:

6th iteration:

i=5

i<size is true because i=5 and size = 35 so 5<35

So the body of loop executes:

 if (sentenceText[i]=='.') statement checks :

if (sentenceText[5]=='.')

This is the character at 5th index of sentenceText i.e. "."

So the if condition evaluates to true and the statement inside if part executes:

sentenceText[i]='!'; statement becomes:

sentenceText[5]='!'; this means that the character at 5th position of sentenceText string is assigned an exclamation mark.

So from above 6 iterations the result is:

Hello!

This loop continues to execute until all the characters of sentenceText are checked and when the value of i gets greater than or equal to the length of sentenceText then the loop breaks.

The screenshot of the program along with its output is attached.

You might be interested in
Which is NOT something that a game producer needs to do?
3241004551 [841]

Answer:

Plan the script, characters, and how the game is played

6 0
3 years ago
During Iteration planning, the PO introduces multiple new stories to the team. After a lot of discussion, the team decides to in
netineya [11]

Answer:

The answer is "Option d".

Explanation:

The Iteration Management is also an activity in which all members of the team will determine how many the backlog team will allocate towards the next Iteration, and each team wraps up the work only as a group of determined iteration targets. in the given question the "choice d" is correct because The plans to achieve without training entered PO or design staff and requirements have not even been identified, and the wrong choice can be defined as follows:

  • In choice A, T' he PO doesn't give the story detail, that's why it's incorrect.    
  • In choice B,  the doesn't a team left the past for more refining with the PO in the Project Backlog, that's why it's incorrect.  
  • In choice C, The Development Team has not found some other team dependency, that's why it's incorrect.

4 0
3 years ago
File names should describe what is in the file in a few words
JulijaS [17]

Answer

File names should describe the content of the file.

Explanation

File names are set of words  which are used to uniquely identify computer files which are stored in a file system. This helps one to know the contents of the file which you want to find. When you name these file names you use necessary characters you use descriptive words so that you dont have hard times when searching for them. The naming also is determined by the file system you are using because different systems impose different restrictions on the length of the file names and the allowed characters within file names.

3 0
3 years ago
give an example of both a negative and positive coping mechanism you could use to deal with this stress?
Andru [333]

Answer:

Negative coping mechanism deals with Substance dependence, abuse, and use; anger, violent mentality, risky mentality, dangerous mentality, reminders such as trauma, etc.

The positive coping mechanism can be like an attempt to transform or change the issue into something other than that. As an example, it can be like converting a stressful situation into a positive situation.

Explanation:

Please check the answer section.

4 0
3 years ago
What is the volume of the prism?
qaws [65]
I think 15 I'm not for sure..
8 0
3 years ago
Other questions:
  • Wendy Patel is entering college and plans to take the necessary classes to obtain a degree in architecture. Research the program
    12·1 answer
  • NullPointerException and ArithmeticException are both derived from which class?
    10·1 answer
  • A trojan horse
    12·1 answer
  • Assume you have taken another square picture with the 25-megapixel digital camera discussed in the previous question. This time
    8·1 answer
  • Who are the four main antagonists in fnaf 1
    13·2 answers
  • For this project, you'll be given information to create a business report using word processing software. Suppose you want to op
    11·1 answer
  • A powerboat is about to cross paths with a sailboat under sail. What should the powerboat do
    5·1 answer
  • Join my FNAF fan club discord
    6·2 answers
  • What is the purpose of the ISOWEEKNUM function? determines how many workdays are in a certain week determines how many workdays
    12·2 answers
  • What starts with p and ends with orn
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!