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
What is one property of a good hash code?
larisa [96]

Answer:- Major property of a good hash code is that objects which are equal should return the same hash code .

Explanation: Hash codes is a numeric value which  is used for identify a object while a equality testing .Hash code can occupy the value of any length and then returns a fixed length value. The value of hash codes are variable.

If two objects are equal then by the method of equal(object) if the hashcode() function is called on both the objects , they produce the same value.

8 0
3 years ago
A finance company wants to upgrade its accounting software to a higher version. This version change requires a change in data fo
Alina [70]

Answer:

The answer to this question is option b which is data re-engineering.

Explanation:

In computer science, data re-engineering is a part of the software development life cycle(SDLC). In the SDLC the data re-engineering is a technique that provides the facility to increase the size of the data formats, design,data-view, etc. It is also known as the software development process in this process, there are seven-stage for software development. If we want to upgrade the software to use the data re-engineering technique so we used the software development process. We use only this process to develop the software because there is no other process to development. So the correct answer is data re-engineering

4 0
2 years ago
Read 2 more answers
Multiple Choice
zalisa [80]
Zeros and ones
Hope the helps
Godspeed
7 0
2 years ago
Change the shape fill color to Dark Red. It is the first option in the Standard Colors section of the color palette.
maxonik [38]
Is this a question ?
3 0
3 years ago
A Google Doc automatically moves text to the next line when it reaches the right edge of the screen, is called:
DanielleElmas [232]
Word Wrap

As the name allows, the word wraps around the document once it reaches the border, thus making it the answer.

Hope this helps!
4 0
3 years ago
Read 2 more answers
Other questions:
  • System software falls into two categories: operating system software and ____ programs.â
    13·1 answer
  • A digital certificate system: Group of answer choices uses digital signatures to validate a user's identity. is used primarily b
    13·1 answer
  • A=1/2h(a+b) solve for h
    6·1 answer
  • Describe an energy problem a city in 2050 will face
    6·1 answer
  • Wrtie down some containerization technology.
    11·1 answer
  • Every command or instruction is called
    8·2 answers
  • What is the purpose of a forecast worksheet?
    15·1 answer
  • Algorithm of how to calculate the area of a square.
    12·2 answers
  • Website managers use____ every day.
    10·2 answers
  • PLEASE HELP! WILL MARK AS BRAINLIEST!
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!