Comparing execution times
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Comparing execution times

  1. #1
    Join Date
    Mar 2014
    Posts
    1

    Comparing execution times

    Hi, I am working on a program for a school assignment. I am not sure exactly how to code this at all. If anyone could help, that would be very much appreciated. This is the problem:

    1+2+3+...+n=(n(n+1))/2

    Write a C++ program that compares the execution time of the above summation using two different solutions: one that uses loops, and another that uses the closed form approach. Use large values of n for the comparisons, such as, 10^7, 10^8, 10^9, 10^10, 10^11,10^12, 10^13, and 10^14. Provide a comparison table for the execution time in both solutions.Do not worry about the value of the actual sum. Overflow will occur in the sum value rendering it invalid; however, this is not the primary concern of the program. Execution time is the primary concern.


    Thank you for your help

  2. #2
    Join Date
    Dec 2012
    Location
    England
    Posts
    4,129

    Re: Comparing execution times

    So how far have you got with this assignment and what is your c++ programming question - as writing code to actually produce the sum in the two ways mentioned is fairly trivial? How have you been told to obtain the execution time of a portion of code? If you post the code you have so far we'll provide guidance and advice.

    See http://forums.codeguru.com/showthrea...ork-assignment
    All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.
    C, C++ Compiler: Microsoft VS2015

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This a Codeguru.com survey!


HTML5 Development Center