Hey everyone,

So I'm new to programming, and my teacher isn't very helpful when it comes to his students running into issues. I have to make this loop (its asking for two separate points to measure the distance) using "if". We are not allowed to use for. I've been experimenting for hours and don't have much to show for it.

Code:

#include <math.h>
#include <stdio.h>
char line [100];
double xc0; /*X coordinate of first point*/
double xc1; /*X coordinate of second point*/
double yc0; /*Y coordinate of first point*/
double yc1; /*Y coordinate of second point*/
double xsqrd, ysqrd, distsqrt;
int answer;
int y;
int n;
int main () {
printf("What is the x coordinate of the first point?"); /*First X Point*/
fgets(line, sizeof(line), stdin);
sscanf(line, "%lf", &xc0);
printf("What is the y coordinate of the first point?"); /*First Y Point*/
fgets(line, sizeof(line), stdin);
sscanf(line, "%lf", &yc0);
printf("What is the x coordinate of the second point?"); /*Second X Point*/
fgets(line, sizeof(line), stdin);
sscanf(line, "%lf", &xc1);
printf("What is the y coordinate of the second point?"); /*Second Y Point*/
fgets(line, sizeof(line), stdin);
sscanf(line, "%lf", &yc1);
xsqrd= pow((xc1-xc0),2); /*First part of formula*/
ysqrd= pow((yc1-yc0),2); /*Second part of forumla*/
distsqrt= xsqrd+ysqrd; /*X and Y values total, will later be under square root*/
printf("The distance between the two points is %lf.\n", sqrt(distsqrt));
printf("Would you like to compute another distance between two points? (y/n)");
fgets(line, sizeof(line), stdin);
sscanf(line,"%i",&answer);
if (answer==y) {
printf("Nugget.\n"); /*Example*/
}
else {
printf("Goodbye.\n");
}
while(1);
return(0);
}

I can get it to say Nugget, but I can't get it to say goodbye. Also, in the end, I need to replace Nugget with the initial program so that it can be repeated over and over again. Can anyone help me out? Thanks.