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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started