Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C Programming. Given the following code, complete the task. #include #include in

ID: 3907796 • Letter: C

Question

C Programming. Given the following code, complete the task.

#include
#include

int main()
{
int degree;
char c[20], weekday[20], dtm[100];

strcpy( dtm, "Saturday * weather 79" );
sscanf( dtm, "%s * %s %d", weekday, c, °ree );

  
return(0);
}

I would like to print a message "Invalid line" when

1) the degree is missing, for example, let's say string is "Saturday * weather ".

2) degree is not a number, for example, string is "Saturday * weather nt"

3) additional information is provided after the degree, for example, string is "Saturday * weather 79 89 21"(79 is the degree)

4) * is missing.

Explanation / Answer

#include #include int main() { int degree; char c[20], weekday[20], dtm[100]; strcpy(dtm, "Saturday * weather 79"); if(sscanf(dtm, "%s * %s %d", weekday, c, °ree) < 3) { printf("Invalid line "); } return (0); }