Question & Answer: Assign the size of userInput to stringSize. Ex: if userInput = "Hello", output is:…..

Assign the size of userInput to stringSize. Ex: if userInput = “Hello”, output is:

Size of userInput: 5

PLEASE show as much commentary as possible and the programming is C.

Expert Answer

 

Program Screenshots:

Sample Output:

Code toCopy:

// Include the necessary header files

#include <stdio.h>

// Start the main method

int main()

{

// Declare the variables.

char userInput[200], i;

// prompt the user to enter the string.

printf(“Enter a string: “);

// Input string

scanf(“%s”, userInput);

// Start the for loop to traverse the string

// Count the number of characters in the string.

for (i = 0; userInput[i] != ‘’; ++i);

// Display the result

printf(“Size of userInput: %dn”, i);

return 0;

}

Still stressed from student homework?
Get quality assistance from academic writers!