Search
 
SCRIPT & CODE EXAMPLE
 

CPP

time of a loop in c++

#include <iostream>
#include <time.h>
using namespace std;

int main()
{
    int finish = 20;
    int start = 1;
    int result = 0;

    double msecs;
    clock_t init, end;

    init = clock();

    for (int i = start; i <= finish; i++)
    {
        result += i;
    }


    end = clock();

    cout << ((float)(end - init)) *1000 / (CLOCKS_PER_SEC);

    system ("PAUSE");

    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: fast way to check if a number is prime C++ 
Cpp :: why is using namespace std a bad practice 
Cpp :: print a string with printf in c++ 
Cpp :: is power of 2 
Cpp :: C++ Volume of a Cylinder 
Cpp :: C++ Area and Perimeter of a Rectangle 
Cpp :: c++ print binary treenode 
Cpp :: c++ thread incide class 
Cpp :: c++ rand include 
Cpp :: stoi() c++ 
Cpp :: modulo subtraction 
Cpp :: c++ ternary operator 
Cpp :: reverse function in cpp array 
Cpp :: Palindrome String solution in c++ 
Cpp :: c++ back() 
Cpp :: substr in cpp 
Cpp :: convert characters to lowercase c++ 
Cpp :: c++ open file explorer 
Cpp :: c++ hash combine 
Cpp :: how to delete an element in vector pair in cpp 
Cpp :: c++ lettura file 
Cpp :: cpp define function 
Cpp :: 31. Next Permutation leetcode solution in c++ 
Cpp :: how to format decimal palces in c++ 
Cpp :: polymorphism in c++ 
Cpp :: overload subscript operator cpp 
Cpp :: C++ Pi 4 Decimal 
Cpp :: get std string from file 
Cpp :: Initialize Vector Iterator 
Cpp :: function c++ example 
ADD CONTENT
Topic
Content
Source link
Name
7+1 =