# Write a program that asks the user to enter a number of seconds.

## Write a C++ program that asks the user to enter a number of seconds.

##### Object:

Write a program that asks the user to enter a number of seconds.

• There are 60 seconds in a minute. If the number of seconds entered by the user is greater than or equal to 60, the program should display the number of minutes in that many seconds.
• There are 3,600 seconds in an hour. If the number of seconds entered by the user is greater than or equal to 3,600, the program should display the number of hours in that many seconds.
• There are 86,400 seconds in a day. If the number of seconds entered by the use is greater or equal to 86,400, the program should display the number of days in that many seconds. Using same method also calculate it for years and month. C++ Project.

## Code:

#include<iostream>
#include<Conio.h>

using namespace std;
void main()
{
double sec;

cout<<“\n\t*******************************************************************\n”;
cout<<“\t\t:C o n v e r t N u m b e r of S e c o n d s:\n”;
cout<<“\t*******************************************************************\n\n”;
cout<<“Enter a Number Of Seconds : “;
cin>>sec;
//Creat condition
if(sec>=31104000)
{
cout<<“\nThe Seconds you Enterd are “<<sec<<” sec. is equal to = “<<sec/31104000<<” year.\n”;
}
else if(sec>=2592000)
{
cout<<“\nThe Seconds you Enterd are “<<sec<<” sec. is equal to = “<<sec/2592000<<” month.\n”;
}
else if(sec>=86400)
{
cout<<“\nThe Seconds you Enterd are “<<sec<<” sec. is equal to = “<<sec/86400<<” day.\n”;
}
else if(sec>=3600)
{
cout<<“\nThe Seconds you Enterd are “<<sec<<” sec. is equal to = “<<sec/3600<<” hour.\n”;
}
else if(sec>=60)
{
cout<<“\nThe Seconds you Enterd are “<<sec<<” sec. is equal to = “<<sec/60<<” minute.\n”;
}
else if(sec<60 && sec>0)
{
cout<<“\nThe Seconds you Enterd are “<<sec<<” sec. is equal to = “<<sec/60<<” sec.\n”;
}
getch();
}

#include<iostream>
#include<Conio.h>

using namespace std;
void main()
{
double sec;

cout<<"\n\t*******************************************************************\n";
cout<<"\t\t:C o n v e r t    N u m b e r    of    S e c o n d s:\n";
cout<<"\t*******************************************************************\n\n";
cout<<"Enter a Number Of Seconds : ";
cin>>sec;
//Creat condition
if(sec>=31104000)
{
cout<<"\nThe Seconds you Enterd are "<<sec<<" sec. is equal to = "<<sec/31104000<<" year.\n";
}
else if(sec>=2592000)
{
cout<<"\nThe Seconds you Enterd are "<<sec<<" sec. is equal to = "<<sec/2592000<<" month.\n";
}
else if(sec>=86400)
{
cout<<"\nThe Seconds you Enterd are "<<sec<<" sec. is equal to = "<<sec/86400<<" day.\n";
}
else if(sec>=3600)
{
cout<<"\nThe Seconds you Enterd are "<<sec<<" sec. is equal to = "<<sec/3600<<" hour.\n";
}
else if(sec>=60)
{
cout<<"\nThe Seconds you Enterd are "<<sec<<" sec. is equal to = "<<sec/60<<" minute.\n";
}
else if(sec<60 && sec>0)
{
cout<<"\nThe Seconds you Enterd are "<<sec<<" sec. is equal to = "<<sec/60<<" sec.\n";
}
getch();
}

## Output:

Another Program: Write a C++ program that will ask user to enter two integral numbers. The numbers should be swapped without using any third variable.