C problem

neilofbodom

Member
Hi

I have just started learning C. I am currently using the Eclipse IDE and I started writing a program which gives the user the distance traveled depending on the speed and the time.

Code:
#include <stdio.h>
#include <stdlib.h>

int main() {

int mph,time;

printf("Enter your speed in miles per hour: ");
scanf("%d",&mph);

printf("Enter your time: ");
scanf("%d",&time);

printf("Distance travelled is: %d", mph*time);

return 0;
}

I do not understand what the problem is. Eclipse is telling me that the program contains errors but I do not know what is wrong with it! Can anyone help??

Cheers
 
What is the error you get? There is nothing syntactically wrong with your program. It runs fine using gcc.
 
I got an error from it in dev-c++. Shown below.
untitled.png
 
If you are bent on using an IDE, then uninstall MinGW, and delete the folder completely.
Else, use a terminal:

mg3eR.png
 
Going to have to agree with the terminal statement. It's way overkill if you are doing something simple like this as it just over complicates things. Write it in the text editor of choice and then compile it from the terminal/command prompt.
Worked fine for me as well:
opr13r.jpg
 
Back
Top