Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Make a flowchart 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];

Make a flowchart 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions

Question

Mrebare a salet budoet unit

Answered: 1 week ago