Separating Integers


Write  a program that inputs one five-digits number, separates the number into its individual digits and prints the digits from one another by three spaces each.







solution

#include<stdio.h>

int main(void)
{

    /*Starting numbers */

    int n;
    int one,two, thr,fov,fiv;

    printf("Enter a five digits:");
    scanf("%d", &n);

    one=n/10000;
    two=(n%10000)/1000;
    thr=((n%10000)%1000)/100;
    fov=(((n%10000)%1000)%100)/10;
    fiv=((((n%10000)%1000)%100)%10)/1;

    printf("%d   %d   %d   %d   %d\n", one, two, thr, fov, fiv);

    return 0;
}

Comments

Popular posts from this blog

Body Mass Index Calculator In C

Adding two Integers in Java Application

Calculating Product, sum, difference, and quotient of Five Integers