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.
Answers
Answer:
scanf("%s%n",&str,&strlen);
Explanation:
it may work
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