Cs604p Assignment 01
Cs604p Assignment 01
ASSIGNMENT NO :01
NAME: AMNA YASEEN
VU ID: BC230429430
C Language Code:
#include <stdio.h>
#include <pthread.h>
#include <string.h>
{
int* arr = (int*)param;
printf("\nIn First Thread \nPrinting the Actual Contents of Array\n");
{
printf("%d\n", arr[i]);
}
printf("\nPrinting the Squares of Number in the Array\n”);
for(int i=0; i<10;i++)
{
printf("%d\n", arr[i]*arr[i]);
}
Printf(“\n”);
return NULL;
}
int main()
{
Pthread_t t1, t2;
int array[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
char str[100];
printf("Enter a String To Pass T2: "):
scanf("%99s", str);
if(pthread_create(&t2, NULL, reverse_string, (void*)str) != 0)
{
perror ("Failed to Create Thread T2");
return 1;
}
pthread_join(t2, NULL);
if(pthread_create(&t1, NULL, calculate_ squares, (void*)array) != 0)
{
perror ("Failed to Create Thread T1");
return 1;
}
pthread_join(t1, NULL);
return 0;
}
Output Screenshot: