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 Armstrong Number series upto a Number

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

2 Ans Write a C program for Binary Search algorithm

1 Ans A C program to input and display an Array

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

1 Ans How to Learn HTML - HyperText Markup Language easily? 

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

2 Ans BPSC aptitude test all programs solutions here

1 Ans Write a C Program to find factorial using recursion

2 Ans BPSC Programming Aptitude Lab Test Important programs