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:

1 Ans A C program to input and display an Array

2 Ans Train Location Message TR Train_Code and Send to 16318 Example: TR 705 Send to 16318

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 find nth Fibonacci number

1 Ans Write a C program to implement x power n using recursion

1 Ans Write a C Program to check Anagrams of two strings

1 Ans Write a C program to check a Palindrome Number

1 Ans A C Program to split a number into digits

1 Ans Single Digit Interest Rate in the Banking Sector: Problems and Prospects - essay writing