How could I rewrite a c code as cuda c code ?

My setup for cuda
cuda 8.0+linux ubuntu 16.04+NVIDIA GEFORCE GTX850M

What the purpose of my learning cuda is to implement data output, parallel computation and output in cuda?
How could I implement that?

For example, the following is a c code . what shoule I do to rewrite it as cuda c code ?

Please give me some advice , thank you !

#include<stdio.h>
#include
double u[641][641];
using namespace std;

void main() {

double h, x, y,nloop;
int nx, ny;
nx = 100;
ny = 100;
nloop = 600;
h = 640/nx;
for (int i = 0; i < nx+1; i++)
{
	for (int j = 0; j < ny+1; j++)
	{
		u[i][j] = 0;
	}
}

for (int k = 0; k < nloop; k++)
{
	for (int i = 0; i < nx+1; i++)
	{
		u[i][0] = 0;
		u[i][ny] = 70;

	}
	for (int j = 0; j < ny+1; j++)
	{
		u[0][j] = 70;
		u[nx][j] = 70;

	}
	for (int i = 0; i < nx+1; i++)
	{
		for (int j = 0; j < ny+1; j++)
		{
			if (j >= i + 490/h)
			{
				u[i][j] = 70;
			}
		}
	}
	
	for (int i = 0; i < nx+1; i++)
	{
		for (int j = 0; j < ny+1; j++)
		{
			if (j >= -i + 1130/h)
			{
				u[i][j] = 70;
			}
		}
	}
	for (int i = 0; i < nx+1; i++)
	{
		for (int j = 0; j < ny+1; j++)
		{
			if ((i-320/h)*(i-320/h)+(j-320/h)*(j-320/h) <= 64/h*64/h)
			{
				u[i][j] = 212;
			}
		}
	}
	for (int i = 1; i < nx; i++)
	{
		for (int j = 1; j < ny; j++)
		{	
			u[i][j] = 0.25*(u[i][j - 1] + u[i][j + 1] + u[i - 1][j] + u[i+1][j]);
		}
	}
}


	

ofstream outf;
outf.open("LAPLACES.txt");
for (int i = 0; i < nx+1; i++)
{
	for (int j = 0; j < ny+1; j++)
	{
		x = i *h;
		y = j *h;
		outf<<x<<" "<<y<<" "<<u[i][j]<<endl;
	}

}
outf.close();


return ;

}