Question: PLEASE WRITE CODE IN RUST PROGRAMMING LANGUAGE NOTE: BOTH CODES ARE INTERLINKED AND NEED CODES FOR BOTH Write a rust program: a. Create a variable

PLEASE WRITE CODE IN RUST PROGRAMMING LANGUAGE

NOTE: BOTH CODES ARE INTERLINKED AND NEED CODES FOR BOTH

Write a rust program:

a. Create a variable score which is equal to 2.

b. Create a closure Add_2 which adds 2 to the variable score.

c. In a for loop call your closure 10 times and print the value of the score.

Write another rust program:

a. create another variable goal which is equal to 2, in your program above.

b. Add a thread multiply_goal to your program above and call a closure inside your thread which is a for loop multiplies variable goal with 2 for 15 times.

c. add a sleep time of 20 milliseconds in the tread, test your program and make sure thread multiply_goal does not stop prematurely.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!