How to pause execution for 5 seconds in C++

1 Answer

0 votes
#include <iostream>
#include <thread>
#include <chrono>

int main() {
    std::cout << "Pausing for 5 seconds..." << std::endl;
    
    std::this_thread::sleep_for(std::chrono::seconds(5));
    
    std::cout << "Resuming execution." << std::endl;
    
    return 0;
}

   
   
/*
run:
   
Pausing for 5 seconds...
Resuming execution.
   
*/

 



answered Apr 29, 2025 by avibootz

Related questions

2 answers 137 views
137 views asked Apr 29, 2025 by avibootz
1 answer 171 views
2 answers 195 views
1 answer 167 views
1 answer 185 views
1 answer 141 views
141 views asked Apr 30, 2025 by avibootz
1 answer 166 views
...