// stringprint.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "mpi.h"
#include<stdio.h>
#include<stdlib.h>
int _tmain(int argc, char* argv[])
{
MPI_Status status;
int numtasks, rank, rc;
char ch;
rc = MPI_Init(&argc,&argv);
if (rc != MPI_SUCCESS)
{
printf ("Error starting MPI program. Terminating.\n");
MPI_Abort(MPI_COMM_WORLD, rc);
}
MPI_Comm_size(MPI_COMM_WORLD,&numtasks);
MPI_Comm_rank(MPI_COMM_WORLD,&rank);
if(rank==0)
{
for (int i = 0; i < 10; i++)
{
ch='A'+rand()%26;
MPI_Send(&ch,1,MPI_INT,1,0,MPI_COMM_WORLD);
}
}
else
{
MPI_Recv(&ch, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &status);
for (int i=ch;i<91;i++)
{
printf("%c",i);
}
}
MPI_Finalize();
return 0;
}
/// i collect this code from my class , but i dont know anything about MPI... how can i run this code without MPI .... please help me...and output will give the same....