Write a function that accepts a pointer to a c string

Assignment Help C/C++ Programming
Reference no: EM131270393

Write a function that accepts a pointer to a C string as an argument and calculates the number of words contained in the string as well as the number of letters in the string. Communicate (or send) both of these values back to the main function, but DO NOT use global variables (variables defined outside of a function).

Write another function that accepts the number of letters and the number of words and sends the average number of letters per word (or average word size) back to the main function.

Demonstrate the functions in a program that asks the user to input a string. First, store the input in a large array. The program should dynamically allocate just enough memory to store the contents of that array. Copy the contents of the large array into the dynamically allocated memory. Then the program should pass that new, dynamically allocated array to the first function. Both the number of words and the average word size should be displayed on the screen. Round the average word size to 2 decimal places.

For instance, if the string argument is "Four score and seven years ago" the first function (word count) should calculate and send back a word count of 6 and a letter count of 25. The second function (average word size) should send back 4.17, or 25 / 6.

Extra challenge: See if you can prevent the program from counting punctuation (such as quotes or periods) as part of the sentence. Also, see if you can prevent the program from counting extra spaces as new words. For instance, 2 spaces will often follow a colon, such as the sentence:

"There are 3 primary colors: red, blue, and green."

In this example, the word count should be 9 (the number 3 does count as a 1-letter word), and the letter count should be 37, for an average of 4.11.

Reference no: EM131270393

Questions Cloud

Should managers promote open discussion of stereotypes : Should managers promote open discussion of stereotypes as part of a strategy for managing diversity? And what are the advantages and disadvantages of strategy
Explain several significant points : Explain several significant points that can be raised about economic goals in terms of definition, complementarity, tradeoffs, and priorities.
Describe the effective use of influence tactics : In your own experience, what is one challenge as well as one benefit in implementing an effective diversity management program? Why is embracing diversity an important role in human resources? Describe the effective use of influence tactics. What ite..
Exchange rate and the balance of payments : Use the following data to work Problems 1 to 3 The U.S. dollar exchange rate increased from $0.96 Canadian in June 2011 to $1.03 Canadian in June 2012, and it decreased from 81 Japanese yen in June 2011 to 78 yen in June 2012
Write a function that accepts a pointer to a c string : Write a function that accepts a pointer to a C string as an argument and calculates the number of words contained in the string as well as the number of letters in the string.
Use definite integrals to approximate total revenues : Use definite integrals to approximate Total revenues taken in over the 2-year period,  Total revenues taken in from t = 8 to t = 14.
Should baseball''s anti-trust exemption be discontinued : Would hosting the 2024 Olympics be a good thing for Los Angeles? Should cities and states provide public support for professional sports stadiums and arenas? Should baseball's anti-trust exemption be discontinued?
What is the x axis (q) looks like : Why the MC (marginal cost) is looks like a ''U''? When the serving is 1 (no extra production) what is the marginal cost? What is the x axis(Q) looks like?
Sketch a three-input rtl nor gate : Sketch a three-input RTL NOR gate. Use a minimum number of transistors.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd