Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function that accepts apointer to a C-String as an argument and returns the number of words contained in the string.For instance, if the

Write a function that accepts apointer 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" thefunction should return the number 6. Demonstrate the function in a program thatasks 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. Modify the program you wrote for problem 1 word counter so it also displays the average number of letters in each word.

So far i have this for my code, but i cant figure out how to display the average number of letters for each word.

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; //Dylan Queary //Also, place your lastnameFirstname on the Project Folder name namespace lastnameFirstname8_2AvgNumOfLetters { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { string s = inputTextBox.Text; string[] words = s.Split(' ');

MessageBox.Show("Number Of Words: " + words.Length); }

private void textBox1_TextChanged(object sender, EventArgs e) {

} } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Build It For The Real World A Database Workbook

Authors: Wilson, Susan, Hoferek, Mary J.

1st Edition

0073197599, 9780073197593

More Books

Students also viewed these Databases questions

Question

4. Not sure? Ask them.

Answered: 1 week ago

Question

What does the start( ) method defined by Thread do?

Answered: 1 week ago