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
Free point giveaway pt.10 and brainliest to first answer
g100num [7]

Answer:

3+3=6

Explanation:

Tysm!!!

8 0
3 years ago
Read 2 more answers
In his work for a new company, Byron found a flower material that he could use to manufacture dresses. In his career, Byron is m
bekas [8.4K]

I guess the correct answer is plant system pathway

Thе plant systеms pathway includеs οccupatiοns rеlatеd tο grοwing fοοd, fееd, and fibеr crοps, and thе study οf plantsand thеir grοwth tο hеlp prοducеrs mееt cοnsumеr dеmand whilе cοnsеrving natural rеsοurcеs and maintaining thе еnvirοnmеnt.

In his work for a new company, Byron found a flower material that he could use to manufacture dresses. In his career, Byron is most likely focused on the plant system pathway.


5 0
3 years ago
Read 2 more answers
if a person walks 10 metres due to south in 10 seconds 10 due east in the next 10 seconds and transmitted you're not in the next
Scorpion4ik [409]

Answer:

\frac{1}{3}\ m/s

Explanation:

The computation of the velocity by using the following formula is

As we know that

Velocity = \frac{Displacement}{Total\ time\ taken}

where,

Displacement is 10 meters

Total time taken is 30 seconds

Now placing these values to the above formula

So, the velocity of Dash is

= \frac{10\ meters}{30\ seconds}

= \frac{1}{3}\ m/s

We simply applied the above formula so that we can get the velocity and the same is to be considered

5 0
3 years ago
How is the United Kingdom planning to use driverless cars beginning in 2015?
AlekseyPX
You need answers to the question

8 0
3 years ago
Read 2 more answers
Name the box where the name of the first cell of the selected range appears?
sergey [27]

Answer:

Name box

Explanation:

From the picture, the name box is at the top left corner with B1 written inside, here B1 is written because it is the active cell at the time which also happens to be the first cell of the selected range. The name box can be used to easily create a named ranges rather Than having to draw the mouse over a group of cells. It also helps to know which cell is the current active cell as the cell address in the name box is the active cell at any point in time.

4 0
3 years ago
Other questions:
  • Computer maker Dell realized the problems with keeping large inventories, especially because of the fast rate of obsolescence of
    7·1 answer
  • The part of the computer that contains the brain or central processing unit is also know as the
    15·2 answers
  • John's Plumbing prides itself on excellent customer service, especially during after-hours service calls. They want to connect w
    11·1 answer
  • By using the search functionality within a twitter stream, users can filter for:
    9·1 answer
  • Match each word to its correct meaning.
    5·1 answer
  • Together with some anthropologists, you’re studying a sparsely populated region of a rainforest, where 50 farmers live along a 5
    15·1 answer
  • computer hardware without software is useless while computer software without hardware is meaningless. explain what do you under
    13·1 answer
  • Define a function compute_gas_volume that returns the volume of a gas given parameters pressure, temperature, and moles. Use
    12·1 answer
  • Which view would you need to use to make changes to the design theme for the entire presentation?
    10·2 answers
  • Memory containing hardwired instructions that the computer uses when it boots up, before the system loads. In PCs the instructio
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!