Check for non zero input value – CSKC
Sign In

Search

Code Learning #CPP#1859    siteicon   siteicon  

Check for non zero input value

Take user input as a positive, negative or zero integer value and check if it is a non zero value.

Learning Objectives

  • Checking if condition by just putting the term value inside, without putting a condition or relational operator.

Source Code

TC++ #1859

 

Source Code

×

Ask AI About This Code

Default Prompt that is passed along with the code is given below, You can write your own prompt if you so desire.



×

Test CPP

Code Understanding

if(n) cout<<“Given number is a non zero value”<<endl;
The term n itself inside if check can return true when it is a non zero term. If it is a 0 value then the condition will be false and nothing will be printed.

 

Notes

  • This kind of usage of term itself as a true or false condition is often done with Boolean variables. Integer variables can also be used easily as in this example.


Suggested Filename(s): checknonzero.cpp



Share

Created: 22-Dec-2017 01:32 | Updated: 15-Sep-2018 11:04|