C Tutorial
This C program gets the number of days as user input and computes the number of weeks and remaining days.
Also finds the number of months and number of years from the number of days user input.
#include<stdio.h> void main() { int days, weeks, months, weeks_rem_days, months_rem_days, years, years_rem_days;; printf("Enter the number of days: "); scanf("%d", &days); weeks = days/7; weeks_rem_days = days % 7; months = days / 30; years = days / 365; weeks_rem_days = days % 7; months_rem_days = days % 30; years_rem_days = days % 365; printf("\nWeeks: %d weeks and %d days,", weeks, weeks_rem_days); printf("\nMonthss: %d months and %d days,", months, months_rem_days); printf("\nYears: %d years and %d days,", years, years_rem_days); }Output:
$ cc arithmetic.c $ ./a.out Enter the number of days: 650 Weeks: 92 weeks and 6 days, Monthss: 21 months and 20 days, Years: 1 years and 285 days,
C Tutorial
Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us | Report website issues in Github | Facebook page | Google+ page