ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 4 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 06 Jun 2017 My Price 9.00

define START_NUMBER 1#define END_NUMBER

Change this program into multi-threaded program, in this case 8 threads.

Do not modify anything in between the comments. Each thread only perform on the number it is given. 

 

#include <stdio.h>#include <sys/time.h>#define START_NUMBER 1#define END_NUMBER 10000FILE *f;int main() {// START: Do not modify anything herestruct timeval start_time, end_time;gettimeofday(&start_time, 0);long unsigned i;f = fopen("./squared_numbers.txt", "w");// END: Do not modify anything herefor (i=START_NUMBER; i<=END_NUMBER; i++) {fprintf(f, "%lu squared = %lu\n", i, i*i);}// START: Do not modify anything herefclose(f);gettimeofday(&end_time, 0);float elapsed = (end_time.tv_sec-start_time.tv_sec) * 1000.0f + \(end_time.tv_usec-start_time.tv_usec) /1000.0f;printf("took %0.2f milliseconds\n", elapsed);// END: Do not modify anything here}

Answers

(11)
Status NEW Posted 06 Jun 2017 04:06 AM My Price 9.00

-----------

Not Rated(0)