c++ cout endl code example
Example 1: C++ and endl
#include <iostream>
using namespace std;
int main () {
int a=100;
double b=3.14;
cout << a;
cout << endl;
cout << b << endl << a*b;
endl (cout);
return 0;
}
Example 2: std ::endl
#include <iostream>
#include <chrono>
template<typename Diff>
void log_progress(Diff d)
{
std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(d).count()
<< " ms passed" << std::endl;
}
int main()
{
std::cout.sync_with_stdio(false);
volatile int sink = 0;
auto t1 = std::chrono::high_resolution_clock::now();
for (int j=0; j<5; ++j)
{
for (int n=0; n<10000; ++n)
for (int m=0; m<20000; ++m)
sink += m*n;
auto now = std::chrono::high_resolution_clock::now();
log_progress(now - t1);
}
}