1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
defon
3 years ago
8

Write a multi-threaded program that outputs prime numbers. The program should work as follows: the user will run the program and

enter a number on the command line. The program creates a thread that outputs all the prime numbers less than or equal to the number entered by the user. Also, create a separate thread that outputs this subset of the above primes that have the following property: the number that is derived by reversing the digits is also prime (e.g., 79 and 97).
Computers and Technology
1 answer:
Ierofanga [76]3 years ago
4 0

Answer:

The programming code can be found in the explanation part, please go through it.

Explanation:

Code:

#include<stdio.h>

#include<stdlib.h>

#include <pthread.h>

// function check whether a number

// is prime or not

int isPrime(int n)

{

// Corner case

if (n <= 1)

return 0;

// Check from 2 to n-1

for (int i = 2; i < n; i++)

if (n % i == 0)

return 0;

return 1;

}

void* printPrimes(void *vargp)

{

int *n = (int *)vargp;

int i=0;

for (i=2;i<=n;i++)

{

if (isPrime(i)) printf("%d\n", i);

}

}

// Driver Program

int main(int argc, char* argv[])

{

int n = atoi(argv[1]);

pthread_t tid;

pthread_create(&tid, NULL, printPrimes, (void *)n);

pthread_exit(NULL);

return 0;

}

You might be interested in
A _____________ is used to make a deep copy of an object.
lesya [120]
The answer is a 3D Printer
3 0
4 years ago
A file with a .bat file extension is called a batch file. You can use a batch file to execute a group of commands, sometimes cal
Elan Coil [88]

Answer:

Create a text file. And add this code in it:

@echo off

You are welcome to the batch programming!

And now save it with .bat file type. Give it any name you want.

And to run the bat file, double click the bat file. It will be running.

You can run it from command prompt as well. Type as below:

C:\folder\batch_name.bat.

Now, we can add as many commands in the file as we want, and we can do the batch programming.

Explanation:

Please check the answer section.

8 0
3 years ago
Which of the following is not a data visualization technique?
Minchanka [31]

Answer:

Normalization

Explanation:

From the options given :

Boxplot is a data visualization techniqye used for representing numerical data in the form of a box such that it adequately conveys the five number summary if the dataset which are the minimum, maximum, lower quartile, median and upper quartile, it also depicts the presence of outlines.

Scatter plot are used depict the relationship between two variables on the x and y axis of a graph. Each point is a representation of the (x, y) value pairs of the observation.

Tag clouds are usually used to represent word, metatdata and other free form text using different colors and font sizes to give information about the data.

Normalization is the odd option out as it is used to restructure data in other to promote integrity of data.

3 0
3 years ago
Select the correct answer. Which keyboard feature is a form feed character? A. uppercase letters B. Control key C. lowercase let
Valentin [98]

Answer:

B . control key

Explanation:

dadadadads

4 0
3 years ago
Why would a brokered CD pay more than a regular CD?
Lana71 [14]

Brokered CDs may have higher or lower rates than those purchased directly from bans and credit unions. The general consensus here is that higher rates are usually available for direct purchases.

3 0
3 years ago
Other questions:
  • The _______ displays the name of the open file and the program.
    13·1 answer
  • Which method of deleting files can be used in windows xp and vista?
    12·1 answer
  • 10010010 + 01100010 =
    11·1 answer
  • You need to synchronize your mobile device data with your desktop computer. for security reasons, your organization prohibits sy
    5·1 answer
  • Several people work with data at Erica’s office. She enters data. One of her coworkers enters new product numbers. Another cowor
    5·1 answer
  • Which of the following is one aspect of gaming that goes relatively unnoticed but
    10·1 answer
  • What are a few ways to format the text in a mail message in Outlook? Check all that apply.
    7·2 answers
  • Briefly the conceptual model of effective computer based instruction for adults outlining three units (output, Process and input
    9·1 answer
  • I’m select circumstances is a permissible character on the Mac operating system
    11·1 answer
  • Sumit has created a procedure to draw a boat in Logo and saved it by the name, 'Boat'. Next day, when he tried to type the name
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!