Monday, April 18, 2022

Convert Days to Years, Weeks and Days in C

 Machine Problem 

Write a program to ask the user to give an input number of days and convert it to years, weeks, and days and display the result on the screen.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.


My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.


My mobile number here in the Philippines is 09173084360.


Please subscribe to my channel  https://www.youtube.com/channel/UCOs-lpOoIeJoh6gpJthPoGg


=================================================


Want to support my channel?

GCash Account

Jake Pomperada

09173084360


Paypal

https://paypal.me/jakerpomperada


Patreon

https://www.patreon.com/jakerpomperada


Thank you very much for your support





Program Listing


/* days.c
Convert days to years weeks and days
Author   : Jake Rodriguez Pomperada, MAED-IT, MIT
Websites  : jakerpomperada.com and jakerpomperada.blogspot.com
Email    : jakerpomperada@gmail.com
Tool     : Dev C++ Version 5.11
Date     : April 18, 2022  5:51 AM  Monday
*/

#include <stdio.h>

int main()
{
   int days=0, years=0, weeks=0;

   system("COLOR F0");
   printf("\n\n");
   printf("\tConvert Days to Years, Weeks and Days in C");
   printf("\n\n");
   printf("\tHow Many Days : ");
   scanf("%d", &days);

    /* Conversion in this portion */
    years = (days / 365);   /* Ignoring leap year */
    weeks = (days % 365) / 7;
    days  = days - ((years * 365) + (weeks * 7));

    printf("\n\n");
    printf("\tDisplay Results");
    printf("\n\n");
    printf("\tNumber of Years : %d\n", years);
    printf("\tNumber of Weeks : %d\n", weeks);
    printf("\tNumber of Days  : %d", days);
    printf("\n\n\n");
    printf("\tEND OF PROGRAM");
    printf("\n\n");
    }



No comments:

Post a Comment