c++ Making sure program doesn't divide by 0 -


i'm writing program check if user inputs 0.0 or variation of 0. however, if write following code user input 0.0 don't either right or wrong output program ends.

int main(){     double num;     cin >> num;     if (num==0){         cout << "wrong";     }     else {         cout <<"right";     } } 

can explain reason don't , possibly how comparison need?

update: code running correct, didn't output because wasn't calling function in main. reason post has code in main simplify question.

it's impossible program have given output nothing. must running different code. may need recompile it. or, might not seeing output reason. try adding \n @ end of strings print, in case next prompt overwriting somehow.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -