Question: Make a flowchart and DFD from this code #include #include #include // Function to reverse date format void reverse_date(char *date_str, char *output) { char year[5],

Make a flowchart and DFD from this code

#include

#include

#include

// Function to reverse date format

void reverse_date(char *date_str, char *output) {

char year[5], month[3], day[3];

sscanf(date_str, "%4s-%2s-%2s", year, month, day);

sprintf(output, "%s/%s/%s", day, month, year);

}

int main() {

char file_name[50];

printf("Enter the course schedule file: ");

scanf("%s", file_name);

// Opening and reading the file

FILE *file = fopen(file_name, "r");

if (file == NULL) {

printf("Error ");

return 0;

}

char line[100], date[11], reason[80];

int absen_count = 0;

while (fgets(line, 100, file)) {

sscanf(line, "%s %[^ ]", date, reason);

char reversed_date[11];

reverse_date(date, reversed_date);

printf("%s %s ", reversed_date, reason);

absen_count++;

}

fclose(file);

if (absen_count > 0 && absen_count < 3) {

int remaining_absen = 3 - absen_count;

printf(" Your remaining absences %s is %d ", strtok(file_name, "."), remaining_absen);

printf("It's okay if you didn't want to come ");

} else if (absen_count == 3) {

printf(" Your absences quota for %s is gone ", strtok(file_name, "."))

} else {

if (absen_count == 0) {

int remaining_absen = 3 - absen_count;

printf("You are never absent ");

printf("It's okay if you didn't want to come %s!!! ", strtok(file_name, "."));

} else {

printf("Time to apologize to your lecturer ");

}

}

return 0;

}

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!