Write a function that accepts a pointer to a C-string as an argument and returns the number of words contained in the string. For instance, if the string argument is 'Four score and seven years ago,' the function should return the number 6. Demonstrate the function in a program that asks the user to input a string and then passes it to the function. The number of words in the string should be displayed on the screen.

Answers

Answer 1

Answer:

To preserve the original format of the answer, I've added it as an attachment

Explanation:

This line defines the function

int countWords(const char ptr){

   

This line initializes number of words to 0

   int words = 0;

The following iteration is repeated until the last character in the argument is reached

   while(*(ptr) != \0){

This checks if current character is blank

       if(*ptr==  ){

If yes, then it increments number of words by 1

        words++;

 }

This moves the pointer to the next character

       ptr++;

   }

This returns the number of words in the argument

   return words+1;

}

The main begins here

int main() {

This declares user input as a character of 200 length

   char userinput[200];

This prompts user for input

   cout << Enter a string: (200 max): ;

This gets user input

cin.getline(userinput, 200);

This passes the c-string to the function and also prints the number of words

cout << There are  << countWords(userinput)<< words;


Related Questions

host a and host b are on the same local network. host a sends a communication to host b. local address resolution is a five-step process, and some of the steps are listed below. select the fourth step that will occur as local address resolution takes place.

Answers

If Host B recognizes its own address, it responds to Host A by updating its cache with Host A's Media Access Control MAC address.

Which OSI reference model layers are host-to-host layers?

Physical, OSI Model; The Transport, Session, Presentation, and Application layers are end-to-end or host-to-host layers, whereas the Datalink and Network layers are hop-to-hop layers.

What is TCP IP's host-to-host layer?

Layer of Host-to-Host Transport. The host-to-host layer is the protocol layer just above the network layer. It is accountable for data integrity from beginning to end. The Transmission Control Protocol (TCP) and the User Datagram Protocol (UDP) are the two most crucial protocols utilized at this layer.

To know more about MAC address visit :-

https://brainly.com/question/27960072

#SPJ4

PLEASE HELP IN C++
Integer numElements is read from input. Given the integer vector yearlySalary with the size of numElements, write a for loop to initialize yearlySalary with the remaining integers read from input, in reverse order.

Ex: If the input is

4

102 107 126 138

then the output is:

138 126 107 102

Answers

Code:

numElements = int(input())  # Read the number of elements from input

yearlySalary = []  # Initialize an empty list

# Read the remaining integers from input and append them to yearlySalary in reverse order

for _ in range(numElements):

   yearlySalary.append(int(input()))

# Reverse the list to obtain the desired order

yearlySalary = yearlySalary[::-1]

# Print the elements in yearlySalary

for salary in yearlySalary:

   print(salary, end=' ')







in this solution, we first read the value of numElements from the input. Then, we initialize an empty list yearlySalary. Next, we use a for loop to read the remaining integers from the input and append them to the yearlySalary list. Finally, we reverse the list using slicing (yearlySalary[::-1]) and print the elements in the desired order.

Feel free giving brainliest!

The C++ standard library provides code that’s organized into a. folders b. namespaces c. sublibraries d. none of the above

Answers

Answer:

Namespaces ( B )

Explanation:

The codes in the C++ standard library are organized into folders Known as  namespaces .

namespaces are general used to organize various codes into logical groups to avoid name collisions that may occur when there is the presence of multiple libraries in a code base.

1. What are the advantages and disadvantages of technology in communication?

Answers

Answer:

ADVANTAGES:

First, the evolution of technology is beneficial to humans for several reasons. At the medical level, technology can help treat more sick people and consequently save many lives and combat very harmful viruses and bacteria.

2-Technology has also increased the productivity of almost every industry in the world. Thanks to technology, we can even pay with bitcoins instead of using banks

DISADVANTAGES:

1-Lack of Privacy. You might think that a quick text or IM offers more privacy than a telephone call in a crowded room. ...

2-Distraction from Real Life. ...

3-Potential for Misunderstanding. ...

4-Decline of Grammar and Spelling...

5- Near people are far and far people are near through communication technology. we have no time to sit with our relatives but constantly communicate far away people . I think this is biggest disadvantage

Explanation:

The advantages and the disadvantages of the communication with the used of the technology are: Quickly communicate and the lack of privacy.

What is communication?

The term communication refers to the exchange of thoughts, ideas, and messages that are shared between two or more people. Without language, a person can survive, but without communication, no one can survive. Communication is divided into two categories, such as interpersonal and intrapersonal.

Advantages of the communication with the used of the technology are:

Quickly communicate.Easy to used.Managed the data and share the data easily.

Disadvantages of the communication with the used of the technology are:

Privacy issues.Hacking Data.They recover the data all the time not to the easy.

Hence, the significance of the communication are the aforementioned.

Learn more about on communication, here:

https://brainly.com/question/22558440

#SPJ2

In Java only please:
4.15 LAB: Mad Lib - loops
Mad Libs are activities that have a person provide various words, which are then used to complete a short story in unexpected (and hopefully funny) ways.

Write a program that takes a string and an integer as input, and outputs a sentence using the input values as shown in the example below. The program repeats until the input string is quit and disregards the integer input that follows.

Ex: If the input is:

apples 5
shoes 2
quit 0
the output is:

Eating 5 apples a day keeps you happy and healthy.
Eating 2 shoes a day keeps you happy and healthy

Answers

Answer:

Explanation:

import java.util.Scanner;

public class MadLibs {

   public static void main(String[] args) {

       Scanner input = new Scanner(System.in);

       String word;

       int number;

       do {

           System.out.print("Enter a word: ");

           word = input.next();

           if (word.equals("quit")) {

               break;

           }

           System.out.print("Enter a number: ");

           number = input.nextInt();

           System.out.println("Eating " + number + " " + word + " a day keeps you happy and healthy.");

       } while (true);

       System.out.println("Goodbye!");

   }

}

In this program, we use a do-while loop to repeatedly ask the user for a word and a number. The loop continues until the user enters the word "quit". Inside the loop, we read the input values using Scanner and then output the sentence using the input values.

Make sure to save the program with the filename "MadLibs.java" and compile and run it using a Java compiler or IDE.

What is the name for the strip of frequently used icons on a computer? O App O Program O Toolbar O Utilities panel ILL MARK YOU BRAINEST​

Answers

Answer: The name of the strip is the Toolbar.

Answer:

its quite obvious toolbar

Explanation:

Which IP QoS mechanism involves prioritizing traffic? Group of answer choices IntServ RSVP COPS DiffServ None of the above

Answers

Answer:

DiffServ

Explanation:

The IP QoS which is fully known as QUALITY OF SERVICE mechanism that involves prioritizing traffic is DIFFERENTIATED SERVICES (DiffServ).

DIFFERENTIATED SERVICES help to differentiate ,arrange ,manage, control and focus on network traffic that are of great significance or important first before network that are less important or by their order of importance in order to provide quality of service and to avoid network traffic congestion which may want to reduce the quality of service when their is to much load on the network .

The boolean expression:
!((A < B) || (C > D))
is equivalent to which of the following expressions?


(A >= B) && (C <= D)

(A >= B) || (C <= D)

(A > B) || (C < D)

(A > B) && (C < D)

(A < B) && (C > D)

Answers

Answer:

(A > B) || (C < D)

Explanation:

Select the correct answer.
Jasmine is a software developer. Her upcoming project requires building system software for a manufacturing plant. The software should be
powerful and fast and provide high performance. Which programming language should she use while programming the manufacturing plant's
system software?
OA PHP
OB. Python
C C++
OD. Java

Answers

Answer: C++

Explanation: it is correct on PLATO

Do you think GE will become one of the top 10 U.S. software companies? Why or why not?

Answers

Answer: I do belive GE will be one of the top 10 software companies because each year the software side of GE is growing 20 perecnt per year which is a big deal!

Explanation:

There are different kinds of firms. I think GE will become one of the top 10 U.S. software companies. The world is gradually turning to the production of electric cars and much more appliances and with this, I believe they would grow to the top 10 in no time.

General Electric Company (GE) is known to be one of the top American multinational conglomerate that is seen in New York State.

It has its headquartered in Boston and thy have been ranked 33rd in the 2020 ranking, among the Fortune 500 in the United States using their gross revenue.

Learn more about General Electric Company from

https://brainly.com/question/26379157

a. If the value in the Elected column is equal to the text "Yes", the formula should display Elected as the text.
b. Otherwise, the formula should determine if the value in the Finance Certified column is equal to the text "Yes" and return the text Yes if true And No if false.

Answers

=IF(Election="Yes","Election",IF(Finance Certified="Yes","Yes","No")) You can accomplish this by nesting one IF function inside of another IF function. The outer IF function determines whether "Yes" or "No" is the value in the Elected column.

How do you utilize Excel's IF function with a yes or no decision?

In this instance, cell D2's formula reads: IF

Return Yes if C2 = 1; else, return No.

As you can see, you may evaluate text and values using the IF function. Error evaluation is another application for it.

What does Excel's between function do?

You can determine whether a number, date, or other piece of data, such text, falls between two specified values in a dataset using the BETWEEN function or formula. A formula is employed to determine whether.

To know more about function visit:-

https://brainly.com/question/28939774

#SPJ1

find a closed form for the given sequence [0,0,0,1,2,4,8,16,.....]​

Answers

The closed form of the sequence [0,0,0,1,2,4,8,16,.....]​ is \(a_n = 2^{n-1}\)

How to determine the closed form?

The sequence is given as:

[0,0,0,1,2,4,8,16,.....]​

Remove the leading zeros

[1,2,4,8,16,.....]​

The above sequence is a geometric sequence, with the following parameters:

First term, a₁ = 1Common ratio, r = 2

The closed form is calculated using:

\(a_n = a_1 * r^{n-1}\)

Substitute the known values

\(a_n = 1 * 2^{n-1}\)

Evaluate the product

\(a_n = 2^{n-1}\)

Hence, the closed form of the sequence [0,0,0,1,2,4,8,16,.....]​ is \(a_n = 2^{n-1}\)

Read more about sequence at:

https://brainly.com/question/6561461

#SPJ1

at least 20 characters

Answers

Answer:

eh?

Explanation:

eh?

Joseline is trying out a new piece of photography equipment that she recently purchased that helps to steady a camera with one single leg instead of three. What type of equipment is Joseline trying out?

A. multi-pod

B. tripod

C. semi-pod

D. monopod

Answers

Joseline trying out tripod .A camera-supporting three-legged stand is known as a tripod. For stability, cameras are fixed on tripods, sometimes known as "sticks." In tripods, the fluid head is used. The camera may now tilt up and down in addition to pan left and right.

What tools are employed in photography?You will need a camera with manual settings and the ability to change lenses, a tripod, a camera case, and a good SD card if you're a newbie photographer who wants to control the visual impacts of photography. The affordable photography gear listed below will help you get started in 2021.A monopod, which is a one-legged camera support system for precise and stable shooting, is also known as a unipod.A camera-supporting three-legged stand is known as a tripod. For stability, cameras are fixed on tripods, sometimes known as "sticks." In tripods, the fluid head is used. The camera may now tilt up and down in addition to pan left and right.

To learn more about tripod refer to:

https://brainly.com/question/27526669

#SPJ1

Answer:

monopod

Explanation:

2. Select the things you can do when working with rows in columns in a spreadsheet:
Freeze a row or column
Delete a row or column
Hide a row or column
Add a row or column
Move rows or columns

Answers

I think you can do all of those things to rows and columns when working with a spreadsheet.

considering the CIA triad and the Parkerian hexed what are the advantages and disadvantges of each model

Answers

Answer:

One of the advantages of CIA is that it can discuss security issues in a specific fashion, and the disadvantage is that it is more restrictive than what we need.

One of the advantages Parkerian hexad is more extensive and complex than the CIA and the disadvantage is it's not as widely known as the CIA.

Dr. Jobst is gathering information by asking clarifying questions. Select the example of a leading question.


"How often do you talk to Dorian about his behavior?"

"Has Dorian always seemed lonely?"

"Did Dorian ever get into fights in second grade?"

"What are some reasons that you can think of that would explain Dorian's behavior?"

Answers

The following is an example of a leading question:
"Did Dorian ever get into fights in second grade?"

An example of a leading question is: "Did Dorian ever get into fights in second grade?" Therefore, option C is correct.

Leading questions are questions that are framed in a way that suggests or encourages a particular answer or direction. They are designed to influence the respondent's perception or show their response toward a desired outcome. Leading questions can unintentionally or intentionally bias the answers given by the person being questioned.

Leading questions may include specific words or phrases that guide the respondent toward a particular answer.

Learn more about leading questions, here:

https://brainly.com/question/31105087

#SPJ2

17. What are the basic modes of operation of 8255?Write the features of mode 0 in 8255?

Answers

Answer:

There are two basic operational modes of 8255:

Bit Set/Reset mode (BSR mode).

Input/Output mode (I/O mode).

Features of 8255 Microprocessor:

Mode 0 : Simple Input/Output.

Mode 1 : Input/Output with handshake.

Mode 2 : Bi-directional I/O data transfer.

It has three 8-bit ports : Port A, Port B, and Port C, which are arranged in two groups of 12 pins.

The 8255 can operate in 3 I/O modes : (i) Mode 0, (ii) Mode 1, & (iii) Mode 2.

What manages and controls the speed of a motherboard's buses? *

RAM
CPU
Chipset
L1 cache

Answers

A bus is simply a circuit that connects one part of the motherboard to another. The back side bus connects the CPU with the level 2 cache. The processor determines the speed of the back side bus. The memory bus connects the northbridge to the memory.

I hope this helps

Chipset manages and controls the speed of a motherboard's buses, Items installed on the motherboard include the CPU and RAM.

What is the speed of a motherboard's buses?

The motherboard is managed by the chipset, it is used to transfer data to and from the CPU and other PC components or PCs.

The path on the motherboard of the PC used to carry data to and from the CPU and other PC components is known as a PC bus, commonly referred to as "the bus." This includes software-to-software communication. The backside bus's speed is set by the processor.

The northbridge and memory are linked by the memory bus. The southbridge is linked to the disk drives through an IDE or ATA bus. The video card is linked to the CPU, memory, and AGP bus.

Therefore, option C is correct.

Learn more about motherboards, here:

https://brainly.com/question/6968002

#SPJ2

one image is 16384 pixels wide and 512 pixels high. He decides to save it as a 256 color bitmap image. Calculate the file size in Gib

Answers

The file size would be 0.268435456 gb

What is a File Size?

This refers to the capacity of a file to store information in it and is a function of memory in computers.

Calculations and Parameters

Given that:

There is a 256 color bitmap image.

The pixel dimensions are: 16384 pixels wide and 512 pixels high (16384 x 512)

To find the file size, this would be:

(16384 x 512 x 256)/8

= 268,435,456 bytes.

Then, to convert bytes to gigabytes and it would be 0.268435456 gb

Read more about digital imaging here:

https://brainly.com/question/26307469

#SPJ1


What is the total March Expenditure now? (cell Q2)

Answers

I did a lot to do it lol was

Is there any difference beetween the old version of spyro released on the origional and the newer ones??? or is it only change in graphix does that mean that the game had to be remade to fit a new console?

Answers

Answer:

yes and no.

Explanation:

the graphics have changed, but there have also been remastered versions of spyro and completely new spyro games

i recommend playing spyros reignited trilogy its three newer spyro games for console

Plz help ASAP

Where are fiber optic cables often used?

A. To connect LANs inside your home

B. To support wireless access points (WAP)

C. To enable near field communications

D. To connect networks that are far apart of that have high data volumes.

Answers

Answer:

D

Explanation:

fiber optic cables are generally used by isps which is why they call their internet fiber optic

xamine the following output:

Reply from 64.78.193.84: bytes=32 time=86ms TTL=115
Reply from 64.78.193.84: bytes=32 time=43ms TTL=115
Reply from 64.78.193.84: bytes=32 time=44ms TTL=115
Reply from 64.78.193.84: bytes=32 time=47ms TTL=115
Reply from 64.78.193.84: bytes=32 time=44ms TTL=115
Reply from 64.78.193.84: bytes=32 time=44ms TTL=115
Reply from 64.78.193.84: bytes=32 time=73ms TTL=115
Reply from 64.78.193.84: bytes=32 time=46ms TTL=115

Which of the following utilities produced this output?

Answers

The output provided appears to be from the "ping" utility.

How is this so?

Ping is a network diagnostic   tool used to test the connectivity between two network devices,typically using the Internet Control Message Protocol (ICMP).

In this case, the output shows   the successful replies received from the IP address 64.78.193.84,along with the response time and time-to-live (TTL) value.

Ping is commonly used to troubleshoot   network connectivity issues and measureround-trip times to a specific destination.

Learn more about utilities  at:

https://brainly.com/question/30049978

#SPJ1

You work at a print shop that produces marketing materials, and your manager asks you to install a new printer. The printer comes with two options for drivers. One uses PCL, and the other uses Postscript. Which driver is the best option and why

Answers

Since you work at a print shop that produces marketing materials, and your manager asks you to install a new printer. The drivers that is best is PCL, because it can be used in the office to print physical document while the Postcript can only be used for online document or pdf and since it is office job, PCL is the best.

What is PCL  printer?

PCL use depends on the device. This indicates that certain printed data, typically graphical data like fill areas, underlines, or fonts, is created by the drivers for this language by using the printer hardware. As a result, the print job can be processed by the computer fast and effectively. The production and processing of page data must then be finished by the printer.

Note that If you typically print from "Office" programs in general, use the PCL driver. If you wish to print PDFs more quickly or use professional DTP and graphics tools for the majority of your printing, pick the PostScript driver.

Learn more about printer driver from

https://brainly.com/question/14230829
#SPJ1

Which term is used to describe RFID chips that don’t have their own power supply?

Answers

The term that is used to describe RFID chips that don’t have their own power supply is Passive RFID systems.

How can RFID chips function?

In order to function, passive RFID tags must be powered by the radio frequency energy that RFID readers and antennas transmit. The reader and antenna send a signal that activates the tag and reflects energy back to the reader.

A battery is frequently the power source for an active RFID tag. RFID passive. The reading antenna's electromagnetic wave causes a current in the RFID tag's antenna, giving the passive RFID tag its power.

Hence, The electromagnetic energy transferred from an RFID reader powers passive RFID tags, which lack an internal power source.

Learn more about RFID from

https://brainly.com/question/25705532
#SPJ1

An internet filter is firewall software used to block a users access to specific internet content. An internet filter can be installed on which three of the following

Answers

An internet filter can be installed on a variety of devices, including:Computers: Internet filters can be installed on individual computers, whether they are desktops, laptops, or tablets.

This allows users to control their own access to certain websites or types of content.Routers: Some routers have built-in internet filtering capabilities, which allow network administrators to control access to specific websites or types of content for all devices connected to the network.Mobile devices: Internet filters can also be installed on smartphones and other mobile devices, which can be particularly useful for parents who want to restrict their children's access to certain types of content while using their mobile devices. internet filters can be installed on a range of devices, depending on the specific needs of the user or organization. By blocking access to certain websites or types of content, internet filters can help to protect users from harmful or inappropriate content, and promote responsible internet use.

To learn more about laptops click the link below:

brainly.com/question/30551024

#SPJ1

What is the second row of letters in the keyboard called?
Brenda typed a few lines on a word processor. She then pressed F7 key to proofread her file. What type of key did Brenda press?

Answers

The Home Row.

A "Function" key.

PLEASEEE HELP
Where could page numbers appear in a properly formatted business document?
A. In document titles
B. In headers or footers
c. In headers only
D. In footers only​

Answers

In the headers or footers

Answer: b

Explanation:

What is computer hardware tools?

Answers

Answer: Well, in basic terms, they are what makes a computer work. Such as the CPU, GPU, Graphics Card, Motherboard, SSD, and HHD.

Explanation:

Other Questions
Let's say that a country produces only 2 final products during a certain period of time: hats and hairdryers. The quantities are 24 hats and 10 hairdryers at a per unit price of $5, and $15 respectively. The country also produces 2 intermediate products (cotton and metals) to help produce the hats and hairdryers; the total value of the intermediate goods is $50. The country's depreciation is $20. What is this country's NDP (Net Domestic Product) during this period of time which action would the nurse take when caring for a client having an acute episode of anxiety? select all that apply. one, some, or all responses may be correct. 35 +5 rational or irrational Which part of a list poem often helps the reader create connections?A. The rhyme schemeB. The titleC. The rhythmD. The last line A 4-cylinder, 4-stroke Otto cycle engine has a bore of 66 mm and a stroke of 54 mm. The clearance volume is 13% and the crankshaft rotates at 3500 rpm. At the beginning of compression, T1 = 27C and P1 = 100KPa. The maximum temperature in the cycle is 2250K. Determine the mean effective pressure.a.18.5 KWb. 18.5 KPac. 840 KWd. 840 KPa find the infer for this picture 1. How far away (in kilometers) is South Florida from Washington, DC? Show howyou found this answer. PLZ HELP ITS TIMED NEED IT RIGHT NOW! THX! multiply and reduce to lowest terms convert into a mixed number if needed 2x 5/6 what is 1.50.90.6=and can you pls show how you slove it Someone helppp pls due in 5 min I will thank Millions of lightning flashes strike the ground annually in the united states causing nearly 100 deaths and 400 injuries. After a practice or game has been suspended due to inclement weather, how long do you wait to return to activities after the flash of lightning?. What is the mass of one mole of AuCl3? Nmeros y direcciones 2. Cual es la direccin de correo electrnico 3. Cual es la direccin de internet 4. Cual es el nmero de fax The fountain and root of a noble life is a good education." Do you agree that the noblest of people have had a good education? Can education only be earned in a school? Where else can a person earn an education? Explain. NEED TO KNOW ASAP PLEASE HELPDescribe the differences between these two transformations. f (x) = (x - 5)^2 and f (x) = x^2-5 What does the statement Ellen bought a pedometer wristband to track how many steps she takes. Each day she recorded the number of steps in a table. At the end of the week, she found her mean number of steps was 10,000. She made a bar graph to show her daily steps for the week. Which graph could show Ellens steps?THANKS SO MUCH!!! Which inequality represents the stated situation : A theater is made to receive no more than 750 spectators. Group of answer choices a client with a recent history of blood in the stools is scheduled for a proctosigmoidoscopy. the nurse should implement which protocols to prepare the client for this procedure? (select all that apply.) Describe what happens to the electrons when sodium and chlorine combine to make NaCl.