#include #include int main(int argc, char** argv) { // Initialize the MPI environment MPI_Init(&argc, &argv); // Get the rank of the process int world_rank; MPI_Comm_rank(MPI_COMM_WORLD, &world_rank); // Get the total number of processes int world_size; MPI_Comm_size(MPI_COMM_WORLD, &world_size); // The broadcast value int broadcast_value; if (world_rank == 0) { // If we are the master process (rank 0), set the broadcast value broadcast_value = 100; printf("Process 0 broadcasting value %d\n", broadcast_value); } // Use MPI_Bcast to broadcast the value from process 0 to all processes MPI_Bcast(&broadcast_value, 1, MPI_INT, 0, MPI_COMM_WORLD); // All processes print the received value printf("Process %d received value %d\n", world_rank, broadcast_value); // Finalize the MPI environment. MPI_Finalize(); }