[SOLVED] Question & Answer: Assign the size of userInput to stringSize. Ex: if userInput = “Hello”, output is:…..
April 24th, 2022
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.
Don't use plagiarized sources. Get Your Custom Essay on
[SOLVED] Question & Answer: Assign the size of userInput to stringSize. Ex: if userInput = “Hello”, output is:…..
From $8/Page
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;
}
assign the size of userinput to stringsize. ex: if userinput = “hello”, output is: