Hi,
I've started programming in C a few weeks ago and have decided to start writing a calculator for every topic/subject I get in maths at school.
When I was writing my most recent, I came across a problem that it would not give the user time to read the final answer at the end. I must be doing something slightly wrong (and probably very stupidly simple aswell lol!). Does anybody know what's wrong with my source code below?
Code:
/* A Program by Jake C to work out the gradient of a line by entering
2 coordinates */
#include <stdio.h>
#include <stdlib.h>
main()
{
char xone[20];
char xtwo[20];
float xintone;
float xinttwo;
char yone[20];
char ytwo[20];
float yintone;
float yinttwo;
float answer;
printf("Please enter the first set of coordinates seperated by a space:\n");
scanf("%s",xone);
scanf("%s",xtwo);
xintone=atof(xone);
xinttwo=atof(xtwo);
printf("Please enter the second set of coordiantes seperated by a space:\n");
scanf("%s",yone);
scanf("%s",ytwo);
yintone=atof(yone);
yinttwo=atof(ytwo);
answer=(yinttwo-yintone)/(xinttwo-xintone);
printf("The gradient of the line is:\n\n%f",answer);
getchar();
return(0);
}
Thanks - I'm new to the forum and it seems like a really informative place! I'm looking forward to being here.
Jake