Practical - 11 - Write a program to Enter days and convert them into years, months and days.

Practical - 11

Aim: Write a program to Enter days and convert them into years, months 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();

}

 

 

 

Output:

Enter Number of Days = 400

 

Years = 1

Months = 1

Days = 5

 

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.

 

Flowchart:



Post a Comment

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