C program to display the odd digits present in integer

Program to display (print) the Odd digits present in the given Integer :

Odd number can not be divided by 2. The remainder after dividing an Odd number by 2 is one. For example . . . Odd digits of number 6547 are 5 and 7. The below given C program is used to display (print) the odd digits present in the given Integer number using if statement. Kindly check out to display the odd digits present in the given Integer number


Program to display (print) odd digits


#include<stdio.h> 

int main(){

               int num,rem,odd=0,digit;

               printf("  Enter an integer number: ");

               scanf("%d",&num);

               printf("\n  The Odd digits present in %d are \n",num);

               while(num>0){

               digit = num % 10;

               num = num / 10;

               rem = digit % 2;

               if(rem != 0)

               printf("\n  %d.",digit);

               }

        return 0; 

    } 

 


Sample outputs:

  Enter an integer number: 2569

 The Odd digits present in 2569 are 

  9

  5

  Enter an integer number: 34587

 The Odd digits present in 34587 are 

  7

  5

  3

 

  • Questions and answers
  • Download Pdf
  • Answers
  • Interviews
  • Solved
  • And College
  • Antivirus Program

Most Related Even or Odd Programs in C


* C program to check even or odd using Bitwise Operator

* C program to find Sum of Odd Digits of a Number

C program to find Sum of Even Digits of a Number

* C program to find Sum of Even and Odd Digits of a Number

* C program to print Odd Digits of a Number

* C program to print Even Digits of a Number

* C program to display Odd numbers from the given N numbers

* C program to display Even numbers from the given N numbers

* C program to check whether a number is odd or even

* C program to check odd or even using if else
* C program to check odd or even using switch case
* C program to check odd or even using function
* C program to check odd or even using Ternary Operator

Bookmark and Share