Basic

Switch Case

Goto

Operators

if Statement

Nested if

While Loop

For Loop

Array

Patterns

Excersises


C Program to Split Number into Digits


In this Example you will learn to Split Three Digit Number into Digits Using Quotient (/) and Remainder (%) Operator in C.

Example : pgm.c

#include<stdio.h>
int main(){
    int n,a,b,c;
    printf("\nEnter Three Digit No : ");
    scanf("%d",&n); //123
    a=n%10;  //3
    n=n/10;  //12
    b=n%10;  //2
    c=n/10;  //1
    printf("\nFirst Digit  : %d",c);
    printf("\nSecond Digit : %d",b);
    printf("\nThird Digit  : %d",a);
    return 0;
}

Output:

Enter Three Digit No : 123
  First Digit      :  1
  Second Digit :  2
  Third Digit     :  3