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 does c++ programming mean?
cestrela7 [59]

Answer:

It's an internal joke to say the language is basically C with some extra stuff (like classes)

the "++" is short for

C += 1 or

C = C + 1 which is a common calculation among programmers so they named it C++ to be a more commercial and attractive name than "C with classes"

Explanation:

8 0
3 years ago
Which of the descriptions listed below best describes the step in the reverse engineering process called functional analysis? A)
Zepler [3.9K]
If multiple choice then d and a if not then the best one would be a!


hope this helps!!
5 0
2 years ago
Cómo se hacían antes las cosas que hoy en día se hacen apoyadas en aplicaciones y software?
KatRina [158]

Answer:

Las cosas que hoy en día se hacen apoyadas en aplicaciones y el software se hacían de manera manual, artesanal o empírica, es decir, antes del avenimiento de la era digital, las tareas que hoy se han automatizado o informatizado se realizaban de forma analógica, mediante procesos con una participación humana mucho más fuerte.

Así, por ejemplo, en el entrenamiento, la medición de variables por parte de los entrenadores respecto de los atletas era procesada de forma manual: la comparación de las distintas estadísticas era recopilada en formato físico, y analizada en forma personal por profesionales idóneos para tal tarea, mientras que hoy en día esa tarea se ha automatizado y es llevada a cabo por programas informáticos específicos.

A su vez, respecto de la tecnología, por ejemplo, el análisis de las variables de mercado y la subida o bajada de distintos valores era sistemáticamente analizada en forma manual, mientras hoy en día diversos programas permiten realizar un análisis técnico y financiero en forma digital.

6 0
3 years ago
I have a summary to write for my robotics class but it is way too hard and i have a bery less time. If you can help me it would
Ierofanga [76]

Answer:

What is Robotics?

Robotics is the branch of technology that deal with the design, construction, operation and application of robots as well as computer system for there control, sensory feed back, and information processing. the design of given robotic system often contain principle of mechanical or electronic engineering and computer science. The word robotic was first used in 1941 by the writer Isaac Asimov.

Branches of robotics:

Artificial intelligence: The developing of an intelligence of machine and is a branch of computer science.

Nano Robotics : the field of creating machines that are at a scale of a nano meter.

Tele-presence: The study given to an illusion of being at a place without being there physically.

Robot Locomotion: The study of method that Robots used to transport them selves from place to another.

Robots have long captured the human imagination but despite many advances robots have yet to reach the potential so often envisioned in science fiction today engineers and computer scientist are still pursuing one missing ingredient high intelligence it would be nice for example: if robots possessed the intelligent needed to cope  with uncertainty, learn from experience and work as team.

Intelligent robots will be one of the engineering achievement of 21 century said Junku Yuh, how leads the robotics program in the national science foundation computers and information science and engineering directorate "we will see them more and more in our daily life".

5 0
3 years ago
Which one of the following oscilloscope controls is used to move the trace up and down the screen vertically? A. Focus B. Sweep
irga5000 [103]
The answer is A Focus hope it helps
7 0
2 years ago
Read 2 more answers
Other questions:
  • . Dеclarе a onе-dimеnsional array of 30 doublеs (on thе stack) namеd rainfall
    11·1 answer
  • Write multiple if statements. if caryear is 1969 or earlier, print "probably has few safety features." if 1970 or higher, print
    6·1 answer
  • Frank is a writer. He needs to work for long hours and type for long periods on the computer. What injury can Frank develop?
    15·2 answers
  • Program documentation _____.
    8·1 answer
  • These items describe guidelines for the effective use of presentation graphics. Graphics should be large enough to be seen by th
    9·1 answer
  • If you wanted a computer to store a variable with the content of “110 Maple Street,” which data type would be most appropriate?
    15·2 answers
  • Which software application offers a variety of templates for creating reports, flyers, and newsletters that you can access withi
    12·1 answer
  • The appropriate semaphore in C to give one more turn to writer so it can clean up IPC objects is WRITE_SEM. Is it true or false
    5·1 answer
  • You are running your warehouse using Autonomous Data Warehouse (ADW) service and you noticed that a newly configured batch job i
    15·1 answer
  • 2. How does the internet give us the ability to communicate?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!