C#: Program to Convert given no. of days into years, weeks and days

In this C# tutorial we are "converting given no of days entered by the user into years, weeks and days" . Here we are taking three variables "y" for years ,"d" for days and "w" for weeks respectively. Now, lets get started!!

using System;
​class prg
{
 public static void Main(String []args)
 {
        int y,d,w;
        Console.WriteLine("Enter no of days : ");
        d=Convert.ToInt32(Console.ReadLine());
        y=d/365;
        d=d%365;
        w=d/7;
        d=d%7;
      Console.WriteLine("Years =" + y + "Weeks =" + w + "Days =" + d);
}
}
SHARE

Raunak Hajela

Hi. I’m CEO/Founder of Kodestat. I’m Student, Geek, Web Designer, Developer, Blog Enthusiast and Player. Inspired to make things looks better. I like playing with codes plus I am marvel fan :-P You can check my design portfolio here. For consulation fell free to drop an email at raunakhajela@gmail.com.

  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment