Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Parallel Processing ProgramsRSS Feeds

PROGRAM TO REVERSE THE GIVEN STRING PARALLELY

Posted By: Abigail Campbell     Category: C Programming     Views: 2444

PROGRAM TO REVERSE THE GIVEN STRING PARALLELY.

Code for PROGRAM TO REVERSE THE GIVEN STRING PARALLELY in C Programming

#include "forkjoin.h"
#include "shared.h"

main()
{
    int a[10],n;
    int *flag,fect=1,nproc;
    int i,pid,shmid;
    char str[20],*d;
    printf("Enter the value of the string : ");
    scanf("%s",str);
    printf("Enter the no. of process  : ");
    scanf("%d",&nproc);
    n=strlen(str);
    d=(char *) create_memory(sizeof(char)*n+1,&shmid);
    pid=create_process(nproc);
    for(i=pid;i<n;i+=nproc)
    {
        d[n-i-1]=str[i];
    }
    join_process(nproc,pid);
    d[i]='\0';
    printf("Reverse string : %s\n",d);
    clear_memory(&shmid);
}
  
Share: 


Didn't find what you were looking for? Find more on PROGRAM TO REVERSE THE GIVEN STRING PARALLELY Or get search suggestion and latest updates.

Abigail Campbell
Abigail Campbell author of PROGRAM TO REVERSE THE GIVEN STRING PARALLELY is from Toronto, Canada.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!