Skip to content
MPGHThe Dark Arts
/
RegisterLog in
Forum
Community
What's NewLatest posts across the boardTrendingHottest threads right nowSubscribedThreads you follow
Discussion
GeneralIntroductionsEntertainmentDebate FortFlaming & Rage
Board
News & AnnouncementsMPGH TimesSuggestions & HelpGiveaways
More Sections
Art & Graphic DesignProgrammingHackingCryptocurrency
Hacks & Cheats
Games
ValorantCS2 / CS:GOCall of Duty / WarzoneFortniteApex LegendsEscape From Tarkov
+14 moreLeague of LegendsGTA VMinecraftRustROTMGBattlefieldTroveBattleOnCombat ArmsCrossFireBlackshotRuneScapeDayZDead by Daylight
Resources
Game Hacking TutorialsReverse EngineeringGeneral Game HackingAnti-CheatConsole Game Hacking
Tools
Game Hacking ToolsTrainers & CheatsHack/Release NewsNew
Submit a release →Share your cheat, tool, or config with the community.
AINEW
AI Tools
General & DiscussionPrompt EngineeringLLM JailbreaksHotAI Agents & AutomationLocal / Open Models
AI × Gaming
AI Aimbots & VisionML Anti-CheatGame Bots & Automation
Create
AI Coding / Vibe CodingAI Art & MediaAI Voice & TTS
The AI frontier →Where game hacking meets modern machine learning. Jump in.
Marketplace
Buy & Sell
SellingBuyingTradingUser Services
Trust & Safety
Middleman LoungeMarketplace TalkVouch Copy Profiles
Money
Cryptocurrency TalkCurrency ExchangeWork & Job Offers
Start selling →List accounts, services, and goods. Use the middleman to trade safe.
MPGH The Dark Arts

A community for offensive security research, reverse engineering, and AI.

Community

ForumMarketplaceSearch

Account

RegisterLog in

Legal

Privacy PolicyForum RulesHelp & FAQ
© 2026 MPGH · All rights reserved.Built by the community, for the community. For educational purposes onlyContent is shared for security research and education — we don't condone illegal use. You're responsible for complying with applicable laws. Use at your own risk.
Home › Forum › Programming › C++/C Programming › time delay to the moon

time delay to the moon

Posts 1–10 of 10 · Page 1 of 1
LA
lalakijilp
time delay to the moon
in my tutorial was a program to calculate the time delay to the mars.

the output is:

Time delay when talking to Mars: 182.796 seconds. This is 3.04659 minutes.

now i wanted to make to look like this:

Time delay when talking to Mars is 3 minutes and ?? seconds.
this is what i did:

but it didn't work out so how can i make it work?

#include <iostream>
using namespace std;

int main ()
{
double distance, lightspeed, delay, delay_in_min, seconds;
int delay_in_min_2;

/* i added int delay_in_min_2; to calculate the seconds left after the whole minutes (minutes-minutes rounded)*60 */

distance = 34000000.0;
lightspeed = 186000;

delay = distance/lightspeed;

cout << "Time delay when talking to mars: " << delay << " seconds." << endl;

delay_in_min= delay/60.0;

cout << "This is " << delay_in_min << " minutes." <<endl;

seconds = (delay_in_min-delay_in_min_2)*60;

// [Warning ] converting to int from double. how to do it else?

delay_in_min_2= ((distance/lightspeed)/60);

cout << "Time delay when talking to mars: " << delay_in_min_2 <<" minutes and " << seconds <<endl;


system ("pause");

return 0;

}
edit: oops wrong title i mean mars. xD
#1 · 17y ago
ZE
zeco
Quote Originally Posted by lalakijilp View Post
in my tutorial was a program to calculate the time delay to the mars.

the output is:

Time delay when talking to Mars: 182.796 seconds. This is 3.04659 minutes.

now i wanted to make to look like this:

Time delay when talking to Mars is 3 minutes and ?? seconds.
this is what i did:

but it didn't work out so how can i make it work?



edit: oops wrong title i mean mars. xD
Well one thing is when you first used delay_in_min_2, it wasn't given a value yet
#2 · edited 17y ago · 17y ago
LA
lalakijilp
Quote Originally Posted by zeco View Post
Well one thing is when you first used delay_in_min_2, it wasn't given a value yet
i changed it but it wont work yet
#3 · 17y ago
rwkeith
rwkeith
Is this C#? Cause I tried working with it and I have a few undefined functions.
#4 · edited 17y ago · 17y ago
LA
lalakijilp
no, it is C++

this was the error.

[Warning ] converting to int from double.

i put it in the code too. hwo to do it otherwise
#5 · 17y ago
rwkeith
rwkeith
Ah, I see almost complete with a solution. By the way, did you get an error about your delay_in_min_2? I had to fix it because my compiler said unknown identifier.
Code:
//myfirst.cpp--displays a msg

#include <iostream>

using namespace std;

int main ()
{
double distance;
double lightspeed;
double delay;
double DelayInMin;
double seconds;
int DelayInMin2;

// I smoothed things into my own style a little =)

distance = 34000000.0;
lightspeed = 186000;

delay = distance/lightspeed;

cout << "Time delay when talking to mars: " << delay << " seconds." << endl;

DelayInMin = delay/60.0;

cout << "This is " << (int)DelayInMin << " minutes." <<endl;
DelayInMin2 = ((distance/lightspeed)/60);//You must declare the variable before using it =), or at least in my case =S
seconds = (DelayInMin-DelayInMin2)*60;

// [Warning ] converting to int from double. how to do it else?



cout << "Time delay when talking to mars: " << (int)DelayInMin2 << " minutes and " << (int)seconds << " seconds.";

cin.get();

return 0;
Ok, simply when you want your answer to be a different type place the type you want it to be in parenthensies. Ex.:

Code:
//This is an example =P

double test = 10.56567
cout << "I will reveal to you an integer: " << (int)test;
The result of this would be 10...
#6 · edited 17y ago · 17y ago
LA
lalakijilp
so you can change a double to an int by putting (int) before it?
#7 · 17y ago
rwkeith
rwkeith
Yes and ignore the (int) I put in this line of code, it isn't required
#8 · 17y ago
why06
why06
Quote Originally Posted by lalakijilp View Post
so you can change a double to an int by putting (int) before it?
Yes. it's called casting a variable. It forces a variable to another type. In Java compilers won't even allow a double value to be entered into a int without casting, but C++ allows a lot more freedom in this regard with it's automatic type conversion. The problem with automatic type conversion is that it can lead to ambiguity too.


Also here is how I would have coded your delay calculator:

Code:
#include <iostream>
using namespace std;

int main()
{
    double distance, delay;
    double SoL = 186000; //miles per second
    
    cout << "LightSpeed Delay Calculator\n" ;
    cout << "Enter distance in miles: \n";
    cin >> distance;
    int seconds = (int)(distance/SoL);
    cout << "The time delay for a distance of " << distance << " miles is " << seconds/60 << " minutes and " << seconds%60 << " second(s).";
    
    system("pause");
    return 0;
}
I used and operator called mod "%" to only return the remainder when I divided the seconds by 60. right now I'm trying to work on a program that will automatically give minutes, hours, days, seconds, etc. depending on the amount of delay. The trouble is keeping all the "/60" and "%60" in my head. I think I will create a funtion to handle this that way only have to call that function and can keep the math out of the cout statements.
#9 · 17y ago
why06
why06
Well it took long enough, and got kinda confusing at times, and I could have gone about it a different way, but here is my completed version that automatically calculates years, days, hours, minutes, and seconds.

Unfortunately it breaks if you inter a value bigger then an integer can hold. It also breaks if you enter something that isn't a number. But hey this is all the effort I'm gonna put into it since I will probably never use it :P

Code:
#include <iostream>
using namespace std;

void time(double seconds);

int main()
{
    double distance, delay;
    double SoL = 186000; //miles per second
    
    cout << "LightSpeed Delay Calculator\n" ;
    cout << "Enter distance in miles: \n";
    cin >> distance;
    
    delay = distance/SoL;
    
    cout <<"The calculated time delay is: ";
    time(delay);
    cout<<endl ;
    
    system("pause");
    return 0;
}
    
// a function that will take parameters in seconds and convert to cyclical time.    

void time(double seconds)
{    
    int minute = 60;
    int hour = 3600;
    int day = 3600*24;
    int year = 3600*24*365;
    
    int second = (int)seconds;
    
    int perfectseconds = second%minute;
    int perfectminutes = ((second/minute)%60);
    int perfecthours =  ((second/hour)%24);
    int perfectdays =  ((second/day)%365);
    int perfectyears = (second/year);

     if(seconds < year)
     {
                if(seconds < day)
                {
                           if(seconds < hour)
                           {
                                      if(seconds < minute)
                                      {
                                                 cout << (int)seconds << " seconds";
                                      }
                                      else cout << perfectminutes << "minutes and " << perfectseconds  << " seconds";
                           }
                           else cout << perfecthours << "hours " << perfectminutes << " minutes and " << perfectseconds << "seconds";
                }
                else cout << perfectdays << "days " << perfecthours << " hours " << perfectminutes << " minutes " << perfectseconds << "seconds";
     }
     else cout << perfectyears << "years " << perfectdays << " days" << perfecthours << " hours " << perfectminutes << " minutes " << perfectseconds << "seconds";
}
you can compile this code and it should run.
#10 · 17y ago
Posts 1–10 of 10 · Page 1 of 1

Post a Reply

Similar Threads

  • Changing the HP,SP,and flag timesBy applesauce in WarRock - International Hacks
    6Last post 20y ago
  • fuck the new york timesBy ace76543 in Flaming & Rage
    13Last post 18y ago
  • PB down for the time beingBy Hispiforce in WarRock - International Hacks
    3Last post 18y ago
  • Click The Link For The Time Of Your Life!By -TM- in Spammers Corner
    0Last post 18y ago
  • Who the fuck put there time into making this.By radnomguywfq3 in General
    12Last post 18y ago

Tags for this Thread

#delay#moon#time