Question: 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!