Tuesday, July 14, 2020
C program to convert days to years, week and days
C Program to convert days into years, week and days:
Write a C program to take days as input form user and convert it to years, weeks and days. Waht is the step by step logic to covert days into years, weeks and days are given below.
Before writing any program you just imagine about output screen first. Like what input to be given, and output to be displayed. Let's have a look at the below example.
1) Print a massage to the user like "Please enter the number of days:" using printf();
2) Input number of days from user and store it in a variable days using scanf();
3) Now convert days to years, weeks and days using below farmula
years = (days / 365); // Ignoring leap year
weeks = (days % 365) / 7;
days = (days % 365) % 7;
4) At last print the resltant values. that's it!
Program to convert days to years, weeks & days:
Output:
Next topic >> to be updated soon.
Help others by sharing this page.
Ahmad Irshad
Author & Editor
I love blogging, teaching, learning computer science and sharing it to others. I've written and develped this site so that students may learn computer science related tutorials eaisly. MCA / MCITP
Tuesday, July 14, 2020
C
Subscribe to:
Post Comments (Atom)
0 Comments:
Post a Comment
Please don't enter any spam link in the comment box.