C++ Program which tell whether a number is zero or not without using comparator operator

ad+1

In this program we will find that input value from user is zero or not, without using comparator operator. For this purpose we will user if-else conditional statement. If user if enter zero then zero will go inside if, and we all know that if statement doesn't work on zero, so else condition will become true and it will be executed.

 Program:

// Program By http://solutionscpp.blogspot.com
// Author Mansoor Ahmed
// GMail ID: secguy000@gmail.com

 
#include<iostream>
using namespace std;

int main()
{
    int n=0;
   
    cout<<"Enter Number: ";
    cin>>n;
   
    if(n)
    {
        cout<<"Number is non-zero";
    }
   
    else
    cout<<"Number is Zero";
}

Output:

3 comments: Leave Your Comments

  1. Hey, I think your site might be having browser compatibility issues. When I look at your blog site in Safari, it looks fine but when opening in Internet Explorer, it has some overlapping. I just wanted to give you a quick heads up! Other then that, fantastic blog!solve afp problems

    ReplyDelete
  2. Really Great Post The Author is very well known about the topic. C++ Programming Complete Notes

    ReplyDelete