answersLogoWhite

0


Best Answer

#include<iostream>

void num_to_years_weeks_days(

unsigned num, unsigned& years,

unsigned& weeks, unsigned& days)

{

years = num / 365;

num -= years * 365;

weeks = num / 7;

num -= weeks * 7;

days = num;

}

int main()

{

unsigned years, weeks, days;

unsigned num = 1000;

num_to_years_weeks_days(num, years, weeks, days);

std::cout << num << " days is " << years << " years, " << weeks << " weeks and " << days << " days\n" << std::endl;

num = 12345;

std::cout << num << " days is " << years << " years, " << weeks << " weeks and " << days << " days\n" << std::endl;

}

User Avatar

Wiki User

9y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a C plus plus program to convert a given number into years weeks and days?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How to write A Java program to print number of digits in a given number?

One way to do this is to convert the number to a String, then use the corresponding String method to find out the length of the String.


Write a c program to find given number is prime or not?

Yes, do write, or if you're too lazy to your homework, use google.


Could you write a assembly language program in tasm To check whether a given number present in a sequence of given memory location containing the string to be checked in 8086?

8086 assembly language program to check wether given number is perfect or not


Write a program in c to convert a given string to lower case?

Use the tolower() function. Example: char* a = 'X'; a = tolower(a); printf("%c", a);


Write a C program to extract a given word from a file?

program to extract a given word from a file


Lab manual in mca 1st sem from ignou?

write a program in C to check whether a given number is apalindrome or not


How can you write a program specification for a given report?

It is your face


Write a C program called MonthDays to find the number of days in a given month Test your code with different input values to demonstrate that your function is robust?

Write a C program called MonthDays to find the number of days in a given month Test your code with different input values to demonstrate that your function is robust?


Shell program for gcd of three given numbers?

write a shell program for finding out gcd of three given numbers? write a shell program for finding out gcd of three given numbers? write a shell program for finding out gcd of three given numbers? check bellow link http://bashscript.blogspot.com/2009/08/gcd-of-more-than-two-numbers.html


How do I convert from jpg to pdf files ?

In order to convert a JPG file to a PDF file you must purchase or download a program. Once you have a program you will be given instructions specific to the program. Just follow the instructions and save your work.


How do you write a program that outputs a given characters in reverse?

write the javascript code to display the reverse no. of given no. (e.g. 247 reverse of 742)


Write a program in C to find the complex number of a given number?

There is no such thing; you seem to have misunderstood something.Any real number can be regarded as a complex number with zero imaginary part, eg.: 5 = 5+0i