0% found this document useful (0 votes)
3 views6 pages

1 (A)

The document contains a C program that defines a structure to represent a day of the week, including its name, date, and associated activity. It initializes an array of seven days with sample data and prints out the calendar for the week. The program demonstrates basic structure usage, string manipulation, and iteration in C.

Uploaded by

Vinod Kulkarni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views6 pages

1 (A)

The document contains a C program that defines a structure to represent a day of the week, including its name, date, and associated activity. It initializes an array of seven days with sample data and prints out the calendar for the week. The program demonstrates basic structure usage, string manipulation, and iteration in C.

Uploaded by

Vinod Kulkarni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

#include <stdio.

h>
#include <string.h>
// Define a structure to
represent a day
struct Day {
char name[20];
int date;
char activity[100];
};
int main() {
// Declare an array of
7 elements to represent
the calendar
struct Day
calendar[7];
// Initialize the
calendar with sample
data
strcpy(calendar[0].name
, "Monday");
calendar[0].date = 1;
strcpy(calendar[0].activi
ty, "Work from 9 AM to 5
PM");
strcpy(calendar[1].name
, "Tuesday");
calendar[1].date = 2;
strcpy(calendar[1].activi
ty, "Meeting at 10 AM");
strcpy(calendar[2].name
, "Wednesday");
calendar[2].date = 3;
strcpy(calendar[2].activi
ty, "Gym at 6 PM");
strcpy(calendar[3].name
, "Thursday");
calendar[3].date = 4;
strcpy(calendar[3].activi
ty, "Dinner with friends
at 7 PM");
strcpy(calendar[4].name
, "Friday");
calendar[4].date = 5;
strcpy(calendar[4].activi
ty, "Movie night at 8
PM");
strcpy(calendar[5].name
, "Saturday");
calendar[5].date = 6;
strcpy(calendar[5].activi
ty, "Weekend
getaway");
strcpy(calendar[6].name
, "Sunday");
calendar[6].date = 7;
strcpy(calendar[6].activi
ty, "Relax and
recharge");
// Print the calendar
printf("Calendar for
the week:\n");
for (int i = 0; i < 7; i+
+) {
printf("%s (Date:
%d): %s\n",
calendar[i].name,
calendar[i].date,
calendar[i].activity);
}
return 0
#include <stdio.h>
#include <string.h>
// Define a structure to represent a day
struct Day {
char name[20];
int date;
char activity[100];
};
int main() {
// Declare an array of 7 elements to represent the calendar
struct Day calendar[7]; // Initialize the calendar with sample data
strcpy(calendar[0].name, "Monday");
calendar[0].date = 1;
strcpy(calendar[0].activity, "Work from 9 AM to 5 PM");
strcpy(calendar[1].name, "Tuesday");
calendar[1].date = 2;
strcpy(calendar[1].activity, "Meeting at 10 AM");
strcpy(calendar[2].name, "Wednesday");
calendar[2].date = 3;
strcpy(calendar[2].activity, "Gym at 6 PM");
strcpy(calendar[3].name, "Thursday");
calendar[3].date = 4;
strcpy(calendar[3].activity, "Dinner with friends at 7 PM");
strcpy(calendar[4].name, "Friday");
calendar[4].date = 5;
strcpy(calendar[4].activity, "Movie night at 8 PM");
strcpy(calendar[5].name, "Saturday");
calendar[5].date = 6;
strcpy(calendar[5].activity, "Weekend getaway");
strcpy(calendar[6].name, "Sunday");
calendar[6].date = 7;
strcpy(calendar[6].activity, "Relax and recharge");
// Print the calendar
printf("Calendar for the week:\n");
for (int i = 0; i < 7; i++) {
printf("%s (Date: %d): %s\n", calendar[i].name, calendar[i].date, calendar[i].activity);

}
return 0;
}

You might also like