Digital जीवन

Free Online Education for India...

Full width home advertisement

Computer Basic

C Programming

Engineering Graphics

Post Page Advertisement [Top]

Dr. A.P.J. Abdul Kalam Technical University, Lucknow

KCS151 / KCS251 Programming for Problem Solving - Using C Language


Lab Exercises


14. Write a program to receive a five-digit no and display it as like 24689: 2 4 6 8 9


/*
 File: Prgrm14.c
 Author: Aditya Saini
 Date: Jan 17, 2021
 Description: Program to receive a five-digit no and display it as like 24689: 2 4 6 8 9
*/

#include <stdio.h>
#include <math.h>

int main (void)
{
     int num;
     int i;

     //Input 5 digit number
     printf ("Input a five digit number: ");
     scanf ("%d", &num);

     //Display
     for (i = 4; num > 0; i--)
     {
          printf ("%d", num / (int) pow (10, i));
          num = num % (int) pow (10, i);
          printf ("\n");
     }

     return 0;
};

Output

Input a five digit number: 12345
1
2
3
4
5




No comments:

Post a Comment

Please do not post spam links.

Bottom Ad [Post Page]

| Designed by Colorlib