#include "mpi.h"
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
int i,id_rank,nop;
char data[50];
MPI_Status st;
MPI_Init(&argc,&argv);
MPI_Comm_size(MPI_COMM_WORLD, &nop);
MPI_Comm_rank(MPI_COMM_WORLD, &id_rank);
if(id_rank==0)
{
printf("Enter the value to be sent to the receiver\n"); MPI_Ssend
(&data
,strlen(data
),MPI_CHAR
,1,1,MPI_COMM_WORLD
);fprintf(stdout
,"i %d process have sent the word %s \n",id_rank
,data
); }
else
{
MPI_Recv(&data,7,MPI_CHAR,1,1,MPI_COMM_WORLD,&st);
fprintf(stdout
, " the data by process %d received is %s\n",id_rank
,data
); {
if(data[i]>=65 &&data[i]<=90)
data[i]+=32;
else
data[i]-=32;
}
MPI_Send
(&data
,strlen(data
),MPI_CHAR
,0,1,MPI_COMM_WORLD
);}
if(id_rank==0)
{
//scanf("%s",data);
MPI_Recv(&data,7,MPI_CHAR,1,1,MPI_COMM_WORLD,&st);
fprintf(stdout
, " the toggled data received is by process %d %s\n",id_rank
,data
); //fprintf(stdout,"i %d process have sent the word %s \n",id_rank,data);
}
MPI_Finalize();
return 0;
}
CiNpbmNsdWRlICJtcGkuaCIKI2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdHJpbmcuaD4KaW50IG1haW4oaW50IGFyZ2MsIGNoYXIgKmFyZ3ZbXSkgIHsKaW50IGksaWRfcmFuayxub3A7CmNoYXIgZGF0YVs1MF07Ck1QSV9TdGF0dXMgc3Q7Ck1QSV9Jbml0KCZhcmdjLCZhcmd2KTsKTVBJX0NvbW1fc2l6ZShNUElfQ09NTV9XT1JMRCwgJm5vcCk7Ck1QSV9Db21tX3JhbmsoTVBJX0NPTU1fV09STEQsICZpZF9yYW5rKTsKaWYoaWRfcmFuaz09MCkKewpwcmludGYoIkVudGVyIHRoZSB2YWx1ZSB0byBiZSBzZW50IHRvIHRoZSByZWNlaXZlclxuIik7CnNjYW5mKCIlcyIsZGF0YSk7Cmlud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