C program to convert days to years weeks and days
Sure! Here’s a C program that converts a given number of days into years, weeks, and remaining days
#include
int main() {
int days, years, weeks, remainingDays;
printf("Enter the number of days: ");
scanf("%d", & days);
years = days / 365;
weeks = (days % 365) / 7;
remainingDays = (days % 365) % 7;
printf("%d days is equivalent to %d years, %d weeks, and %d days.\n", days, years, weeks, remainingDays);
return 0;
}
Output

In this program, we declare four integer variables:
days
to store the input number of days,years
to store the calculated number of years,weeks
to store the calculated number of weeks, andremainingDays
to store the remaining days after calculating the years and weeks.The user is prompted to enter the number of days, which is then stored in the
days
variable using thescanf
function.Next, we perform the calculations to convert the number of days into years, weeks, and remaining days. The
years
variable is assigned the integer division ofdays
by 365, which gives the number of years. Theweeks
variable is calculated by taking the modulus ofdays
by 365 to get the remaining days and then dividing it by 7 to get the number of weeks. Finally, theremainingDays
variable is calculated by taking the modulus ofdays
by both 365 and 7.Finally, we use
printf
to display the result, showing the original number of days and the converted equivalent in years, weeks, and days.

Latest Practical
SELECT AVG(emp_sal)
FROM employee;
SELECT COUNT(*)
FROM employee;