C++ Programming code for implementing integer and floating point division

Asked By 7060 points N/A Posted on -
qa-featured

Hello Experts! I need to write a program that will evaluate the difference in implementing times between integer and floating point division. As an output for testing the program, the operation should be implemented a hundred thousand times and then try to equate the difference in running time. The program must be in C++ Programming Language and the codes should be complete and running correctly. Thanks.

 

SHARE
Answered By 5 points N/A #82675

C++ Programming code for implementing integer and floating point division

qa-featured

 

Hi Rampalvai , hope the following steps will guide you in fixing of this issue.:..:
 
–>The following program may help you in solving your query…
#include <iostream.h>
#include <cmath.h>
#include <cstdlib.h>
#include <time.h.h>
 
//Above all are called as the header files
 
int main( int argc, char* argv )
{
 
    float num = 0;//Declaring num value to zero
    srand( time( NULL ) );
 
    for( signed int i = 0; i < 100000; ++i )
    {
        num += (float)( rand( ) % num );
    }
    std::cin << num << std::end;
 
// Return the values
 
    return (0);
}
 
Thank you..:-)

Related Questions