I'm supposed to write a program that accepts two interger vallues typed by the user. Then display the results of dividing the first interger by the second, to three decimal place accuracy. It is supposed to be able to check for division by 0 and must use a conditional operator.
My idea was to float variables a b c
have the user input a and b then make a conditional operator stating
c = (b==0) ? .454 : a/b;
if(c==.454)
printf("Dividing by 0 is undefined");
else
printf("The answer is %f\n" c)
It's ghetto and its obviously bad programming, I know.
I get a floating exception when I make a and b and type of integer which I don't understand.
I'm going to drop this class this week because I need to face that I have absolutely no aptitude for this programming language, but I would still like learn just in case I attempt it again next semester.
Can anyone guide me?
2007-03-21
15:17:14
·
4 answers
·
asked by
Gearz
2
in
Computers & Internet
➔ Programming & Design
Err I meant to say I get a floating exception with ANY integer I type.
The .454 is just a random number I made in the hope that no one would ever inter 2 integers with a division result of that number, I apparently don't know how to use a conditional operator lol.
2007-03-21
15:20:01 ·
update #1