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 Write a C program to find the highest and lowest number in a series

1 Ans A C program to input and display an Array

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

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

1 Ans Write a C program to reverse a number

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

2 Ans Write a C program for Binary Search algorithm

3 Ans Three ways to find Greatest Common Divisor (GCD) and Least Common Multiple (LCM) in a C program

1 Ans Write a C program to find nth Fibonacci number

1 Ans Which is the best and easy C programming learning website ?