Copyright 2004 by M. Uli Kusterer Thu, 01 Jan 1970 12:00:00 GMT Comments on article book3 at Zathras.de http://www.zathras.de/angelweb/book3.htm book3 Comments witness_dot_of_dot_teachtext_at_gmx_dot_net (M. Uli Kusterer) witness_dot_of_dot_teachtext_at_gmx_dot_net (M. Uli Kusterer) en-us Comment 4 by Colton http://masters-of-the-void.com/book3.htm#comment4 http://masters-of-the-void.com/book3.htm#comment4 I went just a step further and, in my DIVISION if statement, I not only put in the if(vSecondArg == 0) statement, I also nested this:

while(vSecondArg == 0)
{
printf("\nCan't divide by zero. Enter a nonzero int: ");
scanf("%d", &vSecondArg);
fpurge(stdin);
}



This keeps the program going, in case someone enters an accidental zero.
Just a tip :)
Comment 3 by Joshua Friedman http://masters-of-the-void.com/book3.htm#comment3 http://masters-of-the-void.com/book3.htm#comment3 Hey There Uli,
When I type the code above, and also when i copy and paste it into my text editor, the program runs as follows:"

What operation do you want to do?
+
Enter left argument: 1

Enter right argument: 1

-1881139919 + 1 = -1881139918


Thanks for the lessons, btw.
Joshua
Comment 2 by Uli Kusterer http://masters-of-the-void.com/book3.htm#comment2 http://masters-of-the-void.com/book3.htm#comment2 Uli Kusterer writes:
@Robert: No, that's perfectly OK. Since an "if...else" construct counts as only one command, you can provide that as the only command in an else. And since C doesn't care about how much or what whitespace you put in, you can put the "if" on the same line as the "else".
Comment 1 by Robert http://masters-of-the-void.com/book3.htm#comment1 http://masters-of-the-void.com/book3.htm#comment1 Robert writes:
.... confused by modern technology :-) i am amazed my Programm is working just as excepted, but it doesnt exactly look like the example shown here as result.

my (simplified) programm-structure looks like that:

if( vOperation == '+' )
{ }

else if ( vOperation == '-' )
{ }

else if ( vOperation == '*' )
{ }

else if ( vOperation == '/' )
{ }

still ok, or is it problematic in any way?