Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <pthread.h>
- #include <math.h>
- int a, b, c;
- float delta, r1, r2;
- void* solve_equation(void* args) {
- delta = sqrt(b*b-4*a*c);
- if(delta < 0)
- printf("The equation has no roots.\n");
- if(delta == 0) {
- r1 = -b/(2*a);
- printf("The equaion has one root: %0.2f\n", r1);
- }
- if(delta>0) {
- r1 = (-b + sqrt(delta)) / (2*a);
- r2 = (-b - sqrt(delta)) / (2*a);
- printf("root 1=%.2f\nroot 2=%.2f", r1, r2);
- }
- pthread_exit(0);
- }
- int main() {
- pthread_t thrd;
- a=1;
- b=-5;
- c=6;
- pthread_create(&thrd, NULL, solve_equation, NULL);
- pthread_join(thrd, NULL);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement