A company has launched a new text editor that allows user to enter English letters, numbers and whitespaces only. if a user attempts to enter any other type of character, it is counted as a miss. given a string of text, write an algorith to help the developer detect the number of misses by a given user in the given input.
input: the input consists of a string textinput, requesting the text that is entered in the text editot by the use
output: print ana integer representing the number of misses by a given user in the given input.
example: aa a234bc@sad$hsagd
output: 3
Answers
Answered by
4
here is a answer
please mark me as brainliest
Attachments:
Answered by
25
The C program is as follows:
#include <stdio.h>
#include <ctype.h>
int main()
{
int i=0,miss=0;
char input[100];
printf("Input your string: ");
gets(input);
while(input[i] != '\0')
{
if((isalpha(input[i])==0) && (isdigit(input[i])==0) && (isspace(input[i])==0)) miss++;
i++;
}
printf("Number of misses = %d",miss);
return 0;
}
- The above program is in C language.
- We have created two int variables i, miss, and initialized them as 0.
- For the string, we have created a char array and then we have used isalpha, isdigit, isspace functions to check and increase the variable miss according to the situation.
Similar questions
Accountancy,
12 hours ago
Math,
12 hours ago
India Languages,
12 hours ago
Social Sciences,
8 months ago