Deitel & Deitel, C How to Program 3rd Edition, Exercise 2.30

// Write a program that inputs one five-digit number, separates the number into its individual
// digits and prints the digits separated from one another by three spaces each.

#include <stdio.h>

int main() {
int num1, remain, a, b, c, d, e;

scanf("%d", &num1);

a = num1 / 10000;
remain = num1 % 10000;
b = remain / 1000;
remain = remain % 1000;
c = remain / 100;
remain = remain % 100;
d = remain / 10;
remain = remain % 10;
e = remain;
printf("%d-%d-%d-%d-%d\n", a, b, c, d, e);



return 0;
}

Comments

Popular posts from this blog

Deitel & Deitel, C How to Program 6th Edition, Exercise 6.23 (Turtle Graphics)

Deitel & Deitel, C How to Program 6th Edition, Exercise 6.22 (Total Sales)

Deitel & Deitel, C How to Program 6th Edition, Exercise 5.47 (Craps Game Modification)