473,324 Members | 2,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

1.#inf00

7
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. int main()
  6. {
  7. float zav_pot1, zav_pot2, v0, a, kt, g, t;
  8. int x;
  9.  
  10.     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");
  11.     printf("enter starting speed of the vehicle in km/h:\n");
  12.     scanf("%f", &v0);
  13.     printf("Enter reaction time of the driver in seconds:\n");
  14.     scanf("%f", &t);
  15.     printf("enter road conditions:\n1 dry\n2 wet\n3 icy\n");
  16.     scanf("%d", &x);
  17.  
  18.     switch(x)
  19.     {
  20.              case(1):
  21.              kt=0,6;
  22.              break;
  23.              case(2):
  24.              kt=0,3;
  25.              break;
  26.              case(3):
  27.              kt=0,1;
  28.              break;
  29.              default:
  30.              printf("Run program again and ener a valid value!\n");
  31.              system("pause");
  32.              return 0;
  33. }
  34.  
  35.     zav_pot1=(v0*v0)/(2*a);
  36.     zav_pot2=(v0*t)+((v0+v0)/(2*a));
  37.  
  38.     printf("Stoping distance without reaction time is %.f m.\n", zav_pot1);
  39.     printf("Stopping distance with reaction time is %f m.\n", zav_pot2);
  40.     system("PAUSE");    
  41.  
  42.     return 0;
  43. }
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.
Jun 13 '14 #1

✓ answered by Rabbit

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
Rabbit
12,516 Expert Mod 8TB
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.
Jun 13 '14 #2
cecnik
7
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.
Jun 14 '14 #3
cecnik
7
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..
Jun 14 '14 #4
Rabbit
12,516 Expert Mod 8TB
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.
Jun 15 '14 #5
donbock
2,426 Expert 2GB
Looking at line 21 (for example): "kt=0,6;".
Is the locale set such that comma (",") serves as the decimal point?
Jun 16 '14 #6
cecnik
7
again, my unexperience bites me.. in my country we use commas for decimals, doesnt translate in c unfortunately..
thanks by the way
Jun 17 '14 #7
Don't use comas in float...kt=0,6 in this line kt stores only 0....
Jun 18 '14 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

22
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...
1
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...
3
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); ...
9
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...
5
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; ...
0
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
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...
1
isladogs
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...
0
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
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....
0
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...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.