Skip to content
Home » C Program to Check Odd-Even using Pointer

C Program to Check Odd-Even using Pointer

Learn about C Program to Check Odd-Even using Pointer in the below code example. Also refer the comments in the code snippet to get a detailed view about what’s actually happening.

C Program to Check Odd-Even using Pointer

Pointer generally stores address of the assigned variable and its value is accessed using asterisk symbol and hence it could be checked by using if statement.

#include<stdio.h>
int main()
{
  int num, rem;
  int *pnum;
  pnum= &num;
  printf("Enter number: ");
  scanf("%d",pnum); //pnum has address of num
  rem= *pnum % 2;
  if(rem==0)
    printf("%d is even.\n", *pnum);
  else
    printf("%d is odd.\n", *pnum);
  return 0;
}

Output:

Enter number: 8
8 is even.

Enter number: 5
5 is odd.

Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.

Similar Codes :
Largest among three number using pointer & function in C
C Program to find Largest among three number using the pointer