title: In MPI for multiple process scanf taking input only once and assign garbage values to other?
body: <p>I am trying to write MPI code with scanf which will take input for all process individually, but only one process taking the input from user and others assign garbage value to that variable. The program is as below</p>
  
  <pre><code>#include &lt;stdlib.h&gt;
  #include &lt;stdio.h&gt;
  #include "mpi.h"
  #include&lt;string.h&gt;
  
  int main(int argc, char* argv[]) 
  {
  int i, size, rank;
  int arr;
  MPI_Init(&amp;argc, &amp;argv);
  MPI_Comm_size(MPI_COMM_WORLD, &amp;size);
  MPI_Comm_rank(MPI_COMM_WORLD, &amp;rank);
  printf("Enter the number\n");
  scanf("%d",&amp;i);
  
  printf("%d\n",i);
  MPI_Finalize();
  exit(0);
  }
  </code></pre>