Tuesday, 3 March 2015

C++ Program To Check Even Or Odd Using Pointer

Problem:- Write A Program To Find A number Is Even Or Odd Using Pointer or c++ program to find even and odd numbers using function or c++ program to find odd or even using class or c++ program to find even and odd numbers using array or c program to print even numbers in an array or even odd program in c++ using an array or c++ odd or even loop or c++ program to check whether a number is even or odd using a function or c program to check whether a number is prime or not using the function or c program for even or odd using for loop

Check This:- Hacker rank solution for Strings, Classes, STL, Inheritance in C++.

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.

Also Check:- Geeksforgeeks solution for School, Basic, Easy, Medium, Hard in C++.

Extreme Recommended:- If this post is beneficial for you and you want Updates for New post then please like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date for a new post or if you have any Query you can ask there with lots of coders also suggest to your Friends to join and like our page, so we can help our community, and don't forget to Subscribe. Enter your Email and click to subscribe.



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 Check Even Or Odd Using Pointer


You May Also Like


1. C++Program To Calculate Factorial Of A Given Number Using Loop

2. C++ Program To Print A Message Multiple Times Using Loop



Ghanendra Yadav
Ghanendra Yadav

I Am Ghanendra Yadav Owner Of This Website. I Love Programming, Web Developing, Logo Making, Banner And Website designing. Currently I Am Studying In NIT Warangal And Also Working With WSDC( As Web Application Developer ) In NIT Warangal For Any Query Mail Me I Will Answer Within 24 Hours Email:- yghanendra@student.nitw.ac.in

Find me on Social Media

Facebook | Twitter | Google+ | RSS Feed

1 comment: