17: Write a program to enter days and convert them into year, month and days.

Practical - 17

17: Write a program to enter days and convert them into year, month and days.


Program:

#include <stdio.h>

#include <conio.h>

 

void main()

{

    clrscr();

    int year, month, days, n;

 

    printf("Enter Number of Days = ");

    scanf("%d", &n);

 

    year = n / 365;

    month = (n % 365) / 30;

    days = (n % 365) % 30;

 

    printf("\nYears = %d \nMonths = %d \nDays = %d", year, month, days);

    getch();

}


Please follow me for more practicals....


Output:

Enter Number of Days = 400

 

Years = 1

Months = 1

Days = 5


Please follow me for more practicals....



Algorithm:

Step-1: START

Step-2: Declare year, month, days, n.

Step-3: Enter the value of n.

Step-4: year = n / 365.

Step-5: month = (n % 365) / 30.

Step-6: days = (n % 365) % 30.

Step-7: Display year, month, days.

Step-8: STOP.





Please follow me for more practicals....






Flowchart:



Please follow me for more practicals....


 

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.