TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

Program to convert days into years

Program to convert days into years on fibonacci, factorial, prime, armstrong, swap, reverse, search, sort, stack, queue, array, linkedlist, tree, graph etc.

<< Back to PROGRAM

Program to convert days into years

Explanation

Well, we know that one year is the sum of 365 days(non-leap year). So the basic formula to convert days into years is to divide the number of days by number(365).

Number of years = (Number of days ) / 365

Algorithm

  1. Define the number of days to convert into years.
  2. Apply in the formula.
  3. Print the number of years.

Complexity

O(1)


Solution

Python

days= 5555
years= days / 365
print("Number of years is: ");
print(years);

Output:

Number of years is: 15

C

#include<stdio.h>
                   int main() 
                   { int days, years;
		           days= 543;
                   years=  days / 365; 
		           printf("\n\n Number of years is : %d",years);
                   return (0);
    }

Output:

Number of years is: 1

JAVA

public class Main
 {
   public static void main (String args[])
	{	int days, years;
                         days = 799;
                         years = days / 365;
                         System.out.println("Number of years is:"+years);
	}}

Output:

Number of years is: 2

C#

using System;
class main
{   static void Main() 
    {
      int days, years; 
      days =6788;
      years = days / 365;
       Console.WriteLine("Number of years is: "+years);
    }}

Output:

Number of years is: 18

PHP

<?php
       $days = 4446 ;
       $years = ($days)/365 ; 
       echo("Number of years is:  ");
       echo($years);
?>

Output:

Number of years is:  12

Next Topic#




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf