Monday, August 26, 2019

WAP to convert a given number of days into years, weeks, days.

//Program
#include<stdio.h>
void main()

    clrscr();
    int tdays, years, weeks, days, num1;
    prinf("Enter total number of days:");
    scanf("%d",&tdays);
    years = tdays / 365;
    num1 = tdays % 365;
    weeks = num1 / 7;
    days = num1 % 7;
    printf("\n Years = %d ", years);
    printf("\n Weeks =%d ", weeks);
    printf('\n Days=%d ", days);
    getch( );
}

Output:
Enter total number of days:365
Year = 1
Weeks = 52
Days = 365

No comments:

Post a Comment

Write a program to find gcd of two numbers using recursion.

About:  The process in which a function calls itself is called recursion and the corresponding function is called as recursive function. ...