Q:

C++ Program To Check Even Or Odd Using Pointer

0

Logic:-

 As we know that if the number is less than zero than a number is Negative or if a Number is Greater than Zero then the number is Positive or any case number is equal to zero. So in this problem we are comparing if the entered number by the user is less than zero or greater than zero or if the both condition fails than a number is definitely zero or we can say entered a number is zero.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include<iostream>
using namespace std;
int main()
{
  int a;
  int *p1;
  
  p1=&a;
  
  cout<<"Enter The Number You Want to Check \n\n";
  cin>>a;
  
 if(*p1>0)
  {
  cout<<"Number Is Possitive \n";
 }
  else if(*p1<0)
  {
  cout<<"Number Is Negative \n";
 }
  else
  {
  cout<<"Number Is Equal to Zero\n\n";
 }
  return 0;

}

 

Output:

Enter The Number You Want to Check 

10

Number Is Possitive 

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C++ Program To Read Infinite Number And Sort In As... >>