why not print z = 0.1
z=0.2
z=0.3,
but print z = 0.00
CODE
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define NUM_THREADS 3
#define pi 4 * atan(1.0)
double x,s,u,z;
void *PrintHello(void *threadid)
{ x += 0.1;
int tid;
tid = (int)threadid;
printf("Hello World! It's me, thread #%d!\n", tid);
// printf("*** %f ****\n",x);
z = (tid+1)/(10);
printf("\n----%f----\n", z);
u = 100;
for(s = 0.0; s<0.61; s += 0.01)
{
u = u*sin((z-0.1)*pi) - u*sin(z*pi) + u*sin((z+0.1)*pi);
printf("%f \n",u);
}
pthread_exit(NULL);
}
int main (int argc, char *argv[])
{
pthread_t threads[NUM_THREADS];
x = 0;
int rc, t;
for(t=0; t<NUM_THREADS; t++){
printf("In main: creating thread %d\n", t);
rc = pthread_create(&threads[t], NULL, PrintHello, (void *)t);
if (rc){
printf("ERROR; return code from pthread_create() is %d\n", rc);
exit(-1);
}
}
pthread_exit(NULL);
}