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

Explain how the use of Git and a shared public Git repository simplifies the process of managing opensource development when many developers may be working on the same code. Support your answer with an appropriate visual that you find from the internet.

Answers

Answer:

Git is a collaborative software used by members of a group to share and work on the same projects. Github is a web application that uses git to link people working together on a codebase. With git and Github, opensource projects can be accessed and collaborated on by volunteers.

Explanation:

Opensource development is a collaborative group of developers working together on a software or platform with a general public license. When working on an opensource project, each developer is able to folk or get a copy of the repository downloaded to a local computer which they can work on and push or update to the actual online repository if the condition for a change is met.

1. It is acceptable to use a jack that has been
A) O Dropped
B) O Cracked
C) Distorted
D) None of the above

Answers

D. None of the above

Learning Target: Students will work on final project.
You have leamed about video game industry and acquired basic skills to make basic
video games in this class so far. It is time to update your resume and cover letter.
Re-visit your assignments from 9/28-9/29 in this class. You can find that at your
submission in google classroom for this class for the dates mentioned. Type your
resume and cover letter using google docs or MS word professionally. First do
research to find a job opening in a real company. Craft your resume and cover letter
as if you are applying for the job listed. List game projects, coding skills etc. that
could benefit you in finding his job.
1. Check-in/Exit Ticket
2. Resume and Cover Letter

Answers

Answer:

I don't get this question

A .cache is made up of _____ , each of which stores a block along with a tag and possibly a valid/dirty bit

Answers

Answer:

Blocks

Explanation:

A .cache is made up of blocks, each of which stores a block along with a tag and possibly a valid/dirty bit.

Basically, each blocks that makes up the cache stores additional block and sometimes a bit.

________________ are piece of programs or scripts that allow hackers to take control over any system.

Answers

Answer:

Exploits

Explanation:

Exploits can be explained to be a piece of programmed softwares or scripts that can give hackers the opportunity to take control over any system and exploit this system's vulnerabilities. The vulnerability scanners that hackers use includes, Nessus, Nexpose e.tc.

They use these scanners above to search for vulnerabilities.

What are stored procedures? What kind of attack do stored procedures protect from? Identify two reasons why stored procedures are a good mitigation against the specific attack. g

Answers

Answer:

Stored procedures or procedures are subroutines or subprograms in SQL written by the user to accomplish a certain task. it helps to mitigate SQL injection by using markers as placeholders for data input and it streams the query statement and data separately in the database.

Explanation:

The stored procedure used in SQL is a user-defined function. Unlike built-in functions like pi(), they must be called to use them.

SQL injection in query statements is written by hackers to bypass conditions, especially when trying to gain access to other user accounts. Stored procedures use markers or placeholders to prevent this.

g 'write a function that takes as input a list and outs a new list containing all elements from the input

Answers

Answer:

def mylist(*args):

   return args

new_list = mylist(2,3,4,5)

Explanation:

The simple python code above defines a function called mylist that receives multiple length of element as a list and returns the list a new list. The "*args" allows the function to receive any number of item and converts them to a list that is returned in the next statement.

The can also be achieved by simply assigning a squared bracket enclosed list to the variable or with the list() constructor.

1) Write a command line that recursively copy the directories and files inside /etc to your home directory. g

Answers

Answer:

cp -R /etc /home

Explanation:

The command statement above is a Linux command line statement used to copy the directories and subdirectories of the /etc folder.

The 'cp' command is used to conventionally copy files and folders but with the '-R' flag, the specified folder is copied recursively. To copy a folder to another recursively, use the syntax;

cp -R <source folder> <destination folder>

A switch is a device that connects multiple computers into a network in which multiple communications links can be in operation simultaneously. True False

Answers

Answer:

True

Explanation:

A network switch is also called switching hub or a bridging hub. It is a device that connects multiple computers into a network in which multiple communications links can be in operation simultaneously. It makes use of Mac addresses in the forwarding of the data link layer (layer 2) of the OSI model. Types include managed switches, unmanaged switches, smart switches but to mention a few.

please help add header file
/**
* TODO add header file
*/
public static boolean comp(int[][] b, int z, Random rand) {
int x = findWinningMove(b, z);
if(x != -1) {
dropToken(x, b, z);
return true;
}
x = findWinningMove(b, (z + 1) % 2);
if(x != -1) {
dropToken(x, b, z);
return false;
}
do {
x = rand.nextInt(BOARD_WIDTH);
} while(b[BOARD_HEIGHT - 1][x] != -1);
dropToken(x, b, z);
return false;
}

Answers

Answer:

jhgfycgxbhyjuufdxxcgbhjkml;,,,,,,,,,,,,,dfxcg,m .u9cgfbv nmkojihuygfc bvnjmkouhytfgvhbjfjfhngouuhjfcjbhbgfbjghbhjigjkijfbjfjigfijgfg

Explanation:

FELLING GENEROUS GIVING AWAY POINTS:)


Who plays Lol btw (league of legends)
ADD me ign : Davidoxkiller (euw server)

Answers

Answer:

thanksssssssss

Suppose that you have the following declaration:
stack Type stack(50); double num; and the input is
25 64-3 6.25 36-4.5 86 14 -129
Write a C++ code that processes this input as follows: If the number is non-negative, it pushes the square root of the number onto the stack; otherwise it pushes the square of the number onto the stack. After processing these numbers write a C++ code that outputs the elements of the stack.

Answers

Answer:

Explanation:

The code is written in C++:

#include <iostream>

#include <stack>

#include <math.h>

#include <iomanip>

using namespace std;

/*

* Supporting method to print contents of a stack.

*/

void print(stack<double> &s)

{

if(s.empty())

{

cout << endl;

return;

}

double x= s.top();

s.pop();

print(s);

s.push(x);

cout << x << " ";

}

int main(){

// Declaration of the stack variable

stack<double> stack;

//rray with input values

double inputs[] = {25,64,-3,6.25,36,-4.5,86,14,-12,9};

/*

* For each element in the input, if it is positive push the square root into stack

* otherwise push the square into the stack

*/

for(int i=0;i<10;i++){

if(inputs[i]>=0){

stack.push(sqrt(inputs[i]));

}else{

stack.push(pow(inputs[i],2));

}

}

//Print thye content of the stack

print(stack);

}

OUTPUT:

5     8     9     2.5     6     20.25     9.27362     3.74166     144     3

-------------------------------------------------------------------------

Process exited after 0.01643 seconds with return value 0

Press any key to continue . . . -

Write a second ConvertToInches() with two double parameters, numFeet and numInches, that returns the total number of inches.

Answers

Answer:

Answered in C++

double ConvertToInches(double numFeet, double numInches){

   return numFeet*12 + numInches;

}

Explanation:

A foot is equivalent to 12 inches. So, the function converts feet to inches by multiplying the number of feet by 12.

The question is answered in C++

This line defines the method with two parameters

double ConvertToInches(double numFeet, double numInches){

This line converts the input parameters to inches and returns the number of inches

   return numFeet*12 + numInches;

}

To convert 9 feet and 12 inches to inches, the main method of the program can be:

int main(){

   cout<<ConvertToInches(9,12);

   return 0;

}

This above will return 120 because: 9 * 12 + 12 = 120 inches

In Python, programmers use square brackets and an index range to slice multiple characters from a string.


True

False

Answers

(True) jgjgjgbfbfbfbdvdvdvdv

Answer:

True

Explanation:

Many electronic devices use a(n) ?, which contains all the circuit parts in a miniature form.

Answers

Answer:

An integrated circuit is a single, miniature circuit with many electronically connected components etched onto a small piece of silicon or some other semiconductive material. (A semiconductor is a nonmetallic material that can conduct an electric current, but does so rather poorly.)

Explanation:

Many electronic devices use a(n) integrated circuit which contains all the circuit parts in a miniature form.

The use of  integrated circuit is known to be a kind of a single, miniature circuit that has a lot of electronically connected parts that are designed onto a small piece of silicon or semi conductive material.

A lot of electronic components are known to be capacitors, inductors, resistors, diodes, transistors and others.

Learn more about electronic devices from

https://brainly.com/question/11314884

A pre-design document you can use to create a new project quickly

Answers

Answer:

13) B - Landscape and Portrait

14) C - Template

Explanation:

The two print options are known as landscape and portrait and a template is a pre-designed document.

what is one issue when organizing around hierarchical functions

Answers

Answer:

The one issue that arises when organizing around hierarchical functions is the dilution of information caused by the absence of direct communication with the overall boss.

Explanation:

This problem is more pronounced when it takes an organization a longer time before initiating hierarchical functions.  Employees who have grown used to communicating directly with their bosses will now be distanced from them because direct reports to the overall bosses are no longer permitted.  Instead, each functional head is expected to coordinate their group information, have it thoroughly filtered before allowing the overall boss to access it.  One advantage is that functional hierarchies eliminate information overflow.  Unfortunately, some bosses do not feel comfortable, at first, when their organizations commence hierarchical organization of business functions.

Files can be stored on hard drives, network drives, or external drives, but not in the cloud.
True
False

Folders provide a method for organizing files.
True
False

Answers

The first one is false and the second is true

Answer: (1) False, (2) True

Explanation:

Multiple Choice
Which method adds an element at the beginning of a deque?
appendleft
O insertleft
O popleft
addleft

Answers

Answer: appendleft

Explanation: Edge 2021

The method that adds an element for the information at the beginning of a deque is append left. Thus option (A) is correct.

What is an information?

An information refers to something that has the power to inform. At the most fundamental level information pertains to the interpretation of that which may be sensed.

The digital signals and other data use discrete signs or alogrithms to convey information, other phenomena and artifacts such as analog signals, poems, pictures, music or other sounds, and the electrical currents convey information in a more continuous form.

Information is not knowledge itself, but its interpretation is important. An Information can be in a raw form or in an structured form as data. The information available through a collection of data may be derived by analysis by expert analysts in their domain.

Learn more about information here:

brainly.com/question/27798920

#SPJ5

what does "route print" do?

Answers

Answer:Route is a Windows command that displays and updates the network routing table. These activities will show you how to use the route command to display the local routing table.

Explanation:

To prevent long page load times for pages containing images, it is best to use a compressed file format such as JPG, as well as appropriate image dimensions and
resolution.
magnification.
orientation.
colors.

Answers

Answer:

The answer to this question is given below in the explanation section.

Explanation:

The given options to this question are:

resolution. magnification. orientation. colors.

The correct option to this question is 1. i.e.

Resolution.

The resolution of an image determines how many pixels per inch an image contains. Image having a higher resolution takes long page load times for a page and lower resolution takes less page load time. So, to prevent long page load times for pages containing images, it is best to use compressed file formation as well as appropriate image dimension and resolution.

While other options are not correct because:

Magnification, orientation, and color does not affect the page load time. Page load time for images only affected by the dimension and resolution of the images.

Explain how a stored procedure is processed by the DBMS query processor (including the type of return value after the query is processed

Answers

Answer:

The stored procedures in DBMS can be executed with;

EXEC procedure_name

It can also be executed with single or multiple arguments with

EXEC procedure_name (use the at tag here)Address= data1, (use the at tag here)Address= data2;

It returns a status value of the queried table.

Explanation:

A stored procedure is a subroutine used in SQL servers to perform a task on a table in a database or the database itself. The syntax for creating a stored procedure is;

CREATE PROCEDURE procedure_name

And then, other statements can be written to be executed when the procedure is called.

Write a loop to print all elements in hourly_temperature. Separate elements with a -> surrounded by spaces. Sample output for the given program: (must be in python)
90 -> 92 -> 94 -> 95
Note: There is a space after 95.
------------------------------------------------------------------------------------------------------------------------
hourly_temperature = [90, 92, 94, 95]
for temp in hourly_temperature:
for index,temp in enumerate(str(temp)):
if index != len(temp)-1:
print(temp,'->',end=' ')
else:
print(temp, end='')
print('') # print newline
------------------------------------------------------------------------------------------------------------------------
My expected out is:
90 -> 92 -> 94 -> 95
I keep getting:
90 -> 92 -> 94 -> 95 ->
NOTE: I can't edit the last line "print('') #print newline"

Answers

Answer:

Following are the code to this question:

hourly_temperature = [90, 92, 94, 95]#defining a list that holds values

c= 0#defining a variable c

for temp in hourly_temperature:#defining a for loop to count list values

   c+= 1#defining c variable to increment the value of c

   for index,temp1 in enumerate(str(temp)):#defining for loop for spacing the list value

       if index == len(str(temp))-1 and c!= len(hourly_temperature):#defining if block that checks the length of list

           print(temp1,'->',end=' ')#print value

       elif c == len(hourly_temperature) and index == len(str(temp)) - 1:#defining elif block that checks the length of list

           print(temp1, end=' ')#print value

       else:#defining else block

           print(temp1, end='')#print value

Output:

90 -> 92 -> 94 -> 95  

Explanation:

In the above-given code, a list "hourly_temperature" is declared, in which an integer variable c is declared, that holds an integer value that is equal to 0, and two for loop is declared, and in the first loop is used for count list value, and inside the for loop is uses enumerate method to assigns an index for each item and use the conditional statement to check each list value and provide space in each element value.

If you wanted to make the system sequentially consistent, what are the key constrains you need to impose

Answers

Answer:

The call of instructions and data must be sequential, there can be no reordering of instructions but to allow reordering, a fence must be created.

Explanation:

Sequential consistent memory model is able to use instructions when or before processing is done and after processing, so long as the instruction order is sequential.

This is similar to uploading a video on you-tube, the site immediately creates a page for the video even before the video is fully uploaded. Sent tweeter messages are seen by different people at different times, but the messages appear to be arranged sequentially.

What is one feature that differentiates social media information systems (SMIS) from Web site applications? A user has to login to a Web site to use the special features. SMIS do not use browsers. A user can comment on a Web site. SMIS has more users than a Web site. SMIS has connection data

Answers

Answer:

A user has to login to a Web site to use the special features.

Explanation:

This is true because, even though website could be able to give the required information needed at that particular point in time, in order to use the special features found in the website, there is need to login into the website.

For example, Brainly which is a website needs the students to login in-order to ask his or her questions where not clarified with an expected answer gotten from the website.

Networks and the interconnectivity of media have affected our society in that:
A. information is hard to get and has not been democratized.
B. countries have shifted away from a global economy.
C. ideas and information are shared quickly and easily.
O
D. the quantity of media now loses out to quality.

Answers

Ideas and information are shared quickly and easily

Answer:

C. Ideas and information are shared quickly and easily

Explanation:

What is the main advantage of using a WYSIWYG (“what you see is what you get”) editor when constructing a website?
Only one programming language is required.
Websites may have more professional construction.
Knowledge of HTML is not required.
Website templates are not necessary.

Answers

Answer:

The answer to this question is given below in the explanation section.

Explanation:

The correct answer among the given options to this question is:

Knowledge of HTML is not required.

Because when you are constructing a website using WYSIWYG (“what you see is what you get”) editor, then you don't need the knowledge of HTML. Because, when you use WYSIWYG editor to insert button, table, images, text, paragraph, etc. It will automatically insert HTML code behind the page. For example, you can insert a form and a submit button using drag and drop with the help of WYSIWYG (“what you see is what you get”)  editor, for this purpose, you don't need exact knowledge of HTML. WYSIWYG (“what you see is what you get”)  automatically inserts the HTML for the form and button on a website page.

While other options are not correct because:

Using the WYSIWYG (“what you see is what you get”)  editor, you can use different programming languages in your website, such as VB.net, Asp.Net, C#, Javascript, Bootstrap, etc. It is not necessarily that you may have more professional construction and in WYSIWYG (“what you see is what you get”)   website templates are mostly used and modified using WYSIWYG editor.

Answer:

(C):Knowledge of HTML is not required.

what is meant by resources of computer

Answers

This question is not specific enough. However, a computer helps you listen to music, read articles and even novels, draw using online platforms, play games, etc.

Gabby needs to perform regular computer maintenance. What should she do? Check all that apply.

Answers

what are the options ???????????

Answer:

all of them but B

Explanation:

Correct on edge

Question #3
Multiple Choice
Which statement is true?
O A collection is a type of deque.
O A list is a type of deque.
O A deque is a type of list.
O Adeque is a type of collection.

Answers

A deque is a type of list

Answer:

D. A deque i a type of collection

Explanation:

I do computer science too ;3

Other Questions
if f(x)=x^2+4x-12. find f(2) What is the sum of 2x-5x+x+y What is Scrooges job? If he were alive today, what type of job do you think he would have? Why? What happens to the current in a circuit if a 100resistor is removed and replaced by a 200resistor? How does a third party candidate play the role of spoiler in an election? The third party candidate endorses (supports) one of the major party candidates, causing the opponent to win The third party candidate takes votes away from one of the major party candidates causing their opponent to win The third party candidate drops out of the race, eliminating their own chance of winning the election. The third party candidate wins the election f (x) = 3x + 5Solve for x=5 Adventure TimeCome on grab your friendsWe'll go to very distant landsWith Jake the Dog and Finn the HumanThe fun will never end, it's Adventure Time! helphelphelp please!!!!!!!!!!!!!!!!!!!!!! In 2016, sports newscaster Erin Andrews and former wrestler Hulk Hogan were both awarded substantial monetary damages after winning their respective cases involving invasion of privacy. It is believed that the juries in both cases wanted to sanction the defendants by sending a clear message that individual's privacy must be respected regardless of who they are. The type of monetary damages awarded in these two cases are described as: Smooth muscle _____.is only found in the heartappears to have stripescontrols involuntary actionsis also called skeletal muscle 3x + 2(4 + 6x) = 113Explain what you did in each step of your solution. A hospice nurse is working with a patient who has a terminal disease. She is trying to help the patient and his family cope with their stress and grief. What quality is extremely important for a successful hospice nurse? The length of a rectangle is 2 feet less than 4 times the width. The area is 256ft2. Find the dimensions of the rectangle. The action of preventing people from reading certain books or materials aAmendment bTzu cLegalism dCensorship What is the cisterna chyli . Wendy, Carlos yo____ la fila juntos. (hacer) You make $443 per week, and have claimed five exemptions. How much money will be withheld from you in a year? Find the length of the hypotenuse of the right triangle.40048041None of the other answers are correct4026 "Nine more than three times a number is negative six"what is the answer? what is a building