Hey guys. I am writing a C program in order to calculate the position of atoms i
ID: 3627575 • Letter: H
Question
Hey guys. I am writing a C program in order to calculate the position of atoms in a graphene nanoribbon. I am getting a fatal error after entering the length and width, can't seem to identify it. any help would be appreciated.
#include
int main(void)
{
float arr[50][2] = {0,0};
float length, width;
int x =1 , y = 0, i=2;
printf("Input length (x) in Armstrong: ");
scanf("%f", &length);
printf("Input width (y) in Armstrong: ");
scanf("%f", width);
arr[0][0] = .71;
arr[0][1] = 0.0;
while(arr[x][1] <= width)
{
while(arr[x-1][0] < length)
{
if(i%2 == 0)
{
arr[x][0] = arr[x-1][0] + 1.42;
arr[x][1] = arr[x-1][1];
x++;
arr[x][0] = arr[x-1][0] + .71;
arr[x][1] = arr[x-1][1] + 1.23;
x++;
i++;
}
else
{
arr[x][0] = arr[x-1][0] + 1.42;
arr[x][1] = arr[x-1][1];
x++;
arr[x][0] = arr[x-1][0] + .71;
arr[x][1] = arr[x-1][1] - 1.23;
x++;
i++;
}
}
i = 2 ;
arr[x][0] = arr[x-1][0] - .71;
arr[x][1] = arr[x-1][1] + 1.23;
while(arr[x][0] > 0.0);
{
if(i%2 == 0)
{
x++;
arr[x][0] = arr[x-1][0] - 1.42;
arr[x][1] = arr[x-1][1];
x++;
arr[x][0] = arr[x-1][0] - .71;
arr[x][1] = arr[x-1][1] + 1.23;
i++;
}
else
{
x++;
arr[x][0] = arr[x-1][0] - 1.42;
arr[x][1] = arr[x-1][1];
x++;
arr[x][0] = arr[x-1][0] - .71;
arr[x][1] = arr[x-1][1] - 1.23;
i++;
}
}
i = 2 ;
x++;
arr[x][0] = arr[x-1][0] + .71;
arr[x][1] = arr[x-1][1] + 1.23;
}
system("PAUSE");
return 0;
}