d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Easy Question - Beginner
Add Reply New Topic New Poll
Member
Posts: 13,657
Joined: Feb 10 2007
Gold: 1,886.00
Apr 12 2015 02:57pm
Just wrote such easy programme, but after i enter the value when it asks for it, it dont stop the screen with calculations. Whats the problem? Was trying with system ("pause"); but doesnt help. Here is the code:

Quote
#include <stdio.h>
#include <math.h>

#define grawitacja 9.81

float CzasSpadku(float h)
{
return(sqrt(2.0*h/grawitacja));
}
float predkosc(float h)
{
return(grawitacja*CzasSpadku(h));
}
float Vkmh(float v)
{
return(3.6*v);
}
int main()
{
float w;

printf("Podaj wysokosc w metrach : ");
scanf ("%f",&w);
printf("Wysokosc : %0.2f [m]\n", w);
printf("Czas : %0.2f \n", CzasSpadku(w));
printf("P{redkosc : %0.2f [m/s]\n", predkosc(w));
printf("Predkosc : %0.2f [km/h]\n", Vkmh(predkosc(w)));
return (0);
}




This post was edited by Insi_Cannabis on Apr 12 2015 03:00pm
Member
Posts: 13,657
Joined: Feb 10 2007
Gold: 1,886.00
Apr 12 2015 03:01pm
ok now i see that Dev C++ is old and not work on some libraries. Had to use getch and conio, now it freezes after calculation ^^.

t/c
Member
Posts: 23,261
Joined: Dec 17 2006
Gold: 18,129.00
Apr 13 2015 12:12pm
getchar(stdin);

Put that after your calculations. Your program is calculating the stuff, but then it goes straight to return 0 which returns 0 to int main and terminates the program. You need to pause it after the calculations and before the return 0.
Member
Posts: 4,613
Joined: Sep 24 2013
Gold: 21,780.44
Apr 13 2015 12:15pm
Quote (Insi_Cannabis @ 12 Apr 2015 22:57)
Just wrote such easy programme, but after i enter the value when it asks for it, it dont stop the screen with calculations. Whats the problem? Was trying with system ("pause"); but doesnt help. Here is the code:


Please start using english variabel names and write english text

Much more pleasant to read to others
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll