Question: Modify the project below: #include #include / / Author: Nhu Phan / / This program checks the validity of user input based on specific conditions.

Modify the project below:
#include
#include
//Author: Nhu Phan
//This program checks the validity of user input based on specific conditions.
//The input is valid if all alphabetic letters are lowercase, and non-alphabetic letters are limited to digits, whitespace, exclamation point, question mark, or period.
int main()
{
//Declare variables
char ch;
int is_valid=1; //Flag to track the validity of the input
//Prompt user for input
printf("Enter input: ");
//Read characters until a newline character is encountered
while((ch=getchar())!='
')
{
//Check if the character follows the specified conditions
if (!(islower(ch)|| isdigit(ch)|| isspace(ch)|| ch=='!'|| ch=='?'|| ch=='.'))
is_valid =0;
}
//Print the results based on the validity of the input
if (is_valid)
printf("valid");
else
printf("invalid");
return 0;
}
Requirements
Name your program project5_valid.c.
Input characters are command line argument.
Character handling library functions in ctype.h are allowed.
The program should also check if the number of arguments on the command line is greater than 2(including ./a.out as one of the arguments). If the number of arguments is not greater than 2, the program should print "invalid number of arguments".
Follow the format of the examples below.
Examples (your program must follow this format precisely)
Example #1
$ ./a.out spring_24
invalid
Example #2
$ ./a.out 8 little pigs!
valid
Example #3
$ ./a.out
invalid number of arguments
Example #4
$ ./a.out Computer Science?
invalid

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!