Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
How can i terminate or close the whole program by pressing 0?
Posted

As alternative to solution 1, try:

C
printf("please enter the divisor:");
if ( scanf("%d", &d) == 1)
  printf("the quotient is %d\n", 1/d);
 
Share this answer
 
Comments
nv3 26-Feb-15 17:18pm    
Your solutions takes 3 lines! But it is way more sophisticated, I admit :-)
OriginalGriff 26-Feb-15 17:18pm    
Now, why didn't I think of that? :doh:

:thumbsup:
Try:
C++
if (charReadFromKeyboard == '0') exit(0);
 
Share this answer
 
Comments
Richard MacCutchan 26-Feb-15 11:21am    
Some high repper only gave you a 1 for this. Did you upset someone today?
OriginalGriff 26-Feb-15 11:24am    
:laugh: Probably!
CPallini 26-Feb-15 13:24pm    
Simple and to the point, 5. :-)
nv3 26-Feb-15 17:15pm    
I have always wondering how to do that and now I finally know the answer. What a day! My 5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900