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
what are the main technologies that have contributed to be growth and commercialization of the Internet
iren [92.7K]

hope it helps have a good day

5 0
2 years ago
1. What is the Internet?
3241004551 [841]
A place to watch daisy Taylor vids
8 0
3 years ago
Read 2 more answers
Which would be the most appropriate way to estimate -6.1(0.22)? Check all that apply.
Sergeu [11.5K]

Answer:

A.Use rounding to get -6(0.2), and then multiply. and D. use front end estimation to get -6(0.2), and multiply. and B.

Explanation:

just took the test

7 0
2 years ago
Read 2 more answers
What is a client benefit of partnering with Accenture's Intelligent Platform Services<br> (IPS)?
charle [14.2K]
It’s a bot Bc when you do stuff you can believ it
8 0
2 years ago
Hoda needs to create a chart that is associated with an Excel spreadsheet. She needs to ensure that if the data in the spreadshe
omeli [17]

Answer:

Link the chart.

Explanation:

Microsoft Excel is a software application or program designed and developed by Microsoft Inc., for analyzing and visualizing spreadsheet documents.

A spreadsheet can be defined as a file or document which comprises of cells in a tabulated format (rows and columns) typically used for formatting, arranging, analyzing, storing, calculating and sorting data on computer systems.

In this scenario, Hoda needs to create a chart that is associated with an Excel spreadsheet. Also, she wants the data in the spreadsheet to change as soon as the chart in her presentation is updated. Thus, the option she must choose is to link the chart with the spreadsheet.

In the source spreadsheet, she should select a chart and the cell where she wants the hyperlink to appear. Then, she should create a hyperlink that links to the spreadsheet.

8 0
2 years ago
Other questions:
  • What would be the desired output of a home security system?
    6·1 answer
  • What is the difference between HTML and CSS? * 1. CSS is a markup language unlike HTML. 2. HTML is a backend technology and CSS
    12·2 answers
  • A user is experiencing slow performance with their computer. A technician suspects the computer has a virus and runs antivirus s
    12·1 answer
  • Each time the user selects an item from a list box in a web page, a postback occurs, the web page will redisplay, and the page_l
    12·1 answer
  • Give a real life of an if statement
    13·1 answer
  • Write a shell (text-based) program, called first_word.py, that opens the file stuff.txt and prints out the first word of every l
    14·1 answer
  • Suppose you present a project and your supervisor comments that the graphics need to be a higher quality and suggests you replac
    9·2 answers
  • Write a method named removeRange that accepts an ArrayList of integers and two integer values min and max as parameters and remo
    10·1 answer
  • Calculate the resistance of an unknown resistor in a circuit with 30 volts and 6 amps. The formula is R = V/I.
    6·1 answer
  • Location of a video or photoshoot is not important when it comes to preplanning the shoot.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!