- #include <stdio.h>
-
#include <stdlib.h>
-
#include <math.h>
-
-
int main()
-
{
-
float zav_pot1, zav_pot2, v0, a, kt, g, t;
-
int x;
-
-
printf("with this program we will calculate the stoping distance of a car\nwhile taking and not taking in account the reaction time of the driver.\n");
-
printf("enter starting speed of the vehicle in km/h:\n");
-
scanf("%f", &v0);
-
printf("Enter reaction time of the driver in seconds:\n");
-
scanf("%f", &t);
-
printf("enter road conditions:\n1 dry\n2 wet\n3 icy\n");
-
scanf("%d", &x);
-
-
switch(x)
-
{
-
case(1):
-
kt=0,6;
-
break;
-
case(2):
-
kt=0,3;
-
break;
-
case(3):
-
kt=0,1;
-
break;
-
default:
-
printf("Run program again and ener a valid value!\n");
-
system("pause");
-
return 0;
-
}
-
-
zav_pot1=(v0*v0)/(2*a);
-
zav_pot2=(v0*t)+((v0+v0)/(2*a));
-
-
printf("Stoping distance without reaction time is %.f m.\n", zav_pot1);
-
printf("Stopping distance with reaction time is %f m.\n", zav_pot2);
-
system("PAUSE");
-
-
return 0;
-
}
SO again I have a scool asignment.. if you compile and run the program it works fine with one little problem. The values printed in the last part both show as 1.#INF00. I get that this problem ocures due to insufficient bit room or something like that. I would very much appreciate the help.
Please use code tags when posting code or formatted data.
You never define a. Which means a can be anything. In this case, a is probably 0. And you can't divide by 0.
7 2860
Please use code tags when posting code or formatted data.
You never define a. Which means a can be anything. In this case, a is probably 0. And you can't divide by 0.
thanks, I have to be more precise when writing code.. sory for the post btw, new on the forum and still getting used to it.
ok so I added the line "a=kt*9,81;" just above the line "zav_pot1=(v0*v0)/(2*a);" but the problem is still there.. I'm sory if it is realy obvious but I just can't see it..
That should be fine if the values you are passing in aren't too large. I would look at the values of each variable before the calculations to see what's actually stored in there.
Looking at line 21 (for example): "kt=0,6;".
Is the locale set such that comma (",") serves as the decimal point?
again, my unexperience bites me.. in my country we use commas for decimals, doesnt translate in c unfortunately..
thanks by the way
Don't use comas in float...kt=0,6 in this line kt stores only 0....
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Alexandre Proulx |
last post by:
I am trying to find 2 at the power of 601, but my calculator doesn't have a large enough screen, so I decided to make a program for my computer to do this, but when I get to a high number the...
|
by: Phil Clingenpeel |
last post by:
Hi,
I wrote a program to translate a binary file (for which I have the text version) into another binary file (I needed a new format) and text file. There is no division involved, just some...
|
by: aryucc |
last post by:
#include <stdio.h>
int main()
{ float sum, n, a, d, l;
n=l-a+1, d=1, a=1, l=100;
sum=(n/2)*(2*a+(n-1)*d);
printf("The sum of the numbers from %f to %f is %f.", a, l, sum);
...
|
by: abhinuke |
last post by:
As I posted earlier,I ve been practicing C for my upcoming Graduate Studies Venture.Just reading online books and practicing some basic codes.I happen to play with taylors Sinx Series on Netbeans...
|
by: valenwalen |
last post by:
I did my program to calculate pi but for some reason, every single time I run the program, screen says "1.#INF00":
#include<stdio.h>
#include<stdlib.h>
int main (void)
{
float a;
...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |