Tuesday, 3 March 2015

C++ Program To Find Number Is Even Or Odd Using Pointer

Problem :- Write A Program To Find A number Is Even Or Odd Using Pointer

Logic :- As we know that if number is less than zero than number is Negative or if a Number is Greater than Zero then number is Positive or any case number is equal to zero .

Solution :-

#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:-

C++ Program To Find Number Is Even Or Odd Using Pointer

1 comment:
Write comments

Recommended Posts × +