Computer Science, asked by haritha13400, 6 months ago

Fill in the blank with code so that the program accepts a string str and prints the length of the string str as the output.

Attachments:

Answers

Answered by swethaDK
6

Answer:

scanf("%s%n",&str,&strlen);

Explanation:

it may work

Answered by sourasghotekar123
0

Answer:

scanf(”%s”, str) in the blank accepts a string str and prints the length of the string str as the output.

One possible way to fill in the blank with code so that the program accepts a string str and prints the length of the string str as the output is:

#include <stdio.h>

int main() { char str[101];

int strlen = 0;

printf(“Enter a string: “);

scanf(”%s”, str);

for(int i = 0; str[i] != ‘\0’; i++) { strlen++;

printf(“The length of the string is %d\n”, strlen);

return 0;

}

Another possible way to fill in the blank with code is:

#include <stdio.h>

#include <string.h>

int main() { char str[101];

int strlen;

printf(“Enter a string: “);

scanf(”%s”, str);

str strlen = strlen(str);

printf(“The length of the string is %d\n”, strlen);

return 0;

}

For more questions on Computer Science

https://brainly.in/question/16501902

#SPJ3

Similar questions