Ask Question - Get Answer

1 Ans A C Program to split a number into digits

Asked by Birds of the sky (2 Golds) Sunday, 03 Jan 2021, 04:15 AM at (Education Tutorials)

Please log in to answer, like and save
1
Save 0

<<< Previous
Log in to Answer Next >>>

Answer(s):

#include<stdio.h>

void call(int n)

{

    int i;

    if(n>0)

    {

        i=n%10; //printf("i = %d ", i);

        n=n/10; //printf("n = %d\n", n);

        call(n);

        printf("%d ", i);

    }

}

int main()

{

    int n;

    scanf("%d", &n);

    call(n);

    return 0;

}

/*
Input: 123
output: 1 2 3
*/

Answered by Birds of the sky (2 Golds) Sunday, 03 Jan 2021, 04:17 AM

Please log in to Upvote, Downvote and Report
           

Related Q/A:

2 Ans Write a C program to implement Selection sort data structure and algorithm

1 Ans Write a C program to check a Palindrome Number

1 Ans Write a C program to check a perfect number

1 Ans Write a C Program to find factorial using recursion

1 Ans Write a C program to check a Prime number

1 Ans A Quest for Peace in the Middle East: Recent Perspectives - composition

1 Ans Write a C program to print Fibonacci number using recursion

1 Ans Write a C program to check Bubble sort data structure and algorithm

1 Ans Write a C program to Find Armstrong Number series upto a Number

1 Ans Write a C program to reverse a number