enter 5 digit number s and have them display in single digits,using division and the remainder mod.
This is what i have so far but it doesnt seem to work.
#include <stdio.h>
int main()

{
int num1,num2,num3,num4,num5,number;
printf("enter five digit number");
scanf("%d,%d,%d,%d,%d",&num1,&num2,&num3,&num4,&num5);
num1r=(number-(number%10000))/10000;
num2=(number%10000-(number%1000))/1000;
num3=(number%1000-(number%100))/100;
num4=(number%100-(number%10))/10;
num5=(number%10-(number%1))/1;
printf("first number is %d%d%d%d%d ",num1,num2,num3,num4,num5);
}

Recommended Answers

All 4 Replies

Member Avatar for iamthwee

The number you enter has to be one single integer not five separate ones.

but will my code work if i enter one single digit?

if the idea of the program is to separate the digits of a number like this

Input 45378
Output 4 5 3 7 8

what you have to do is to save the number and then split it

>> scanf("%d,%d,%d,%d,%d",&num1,&num2,&num3,&num4,&num5);
here you try to save 5 different numbers.

and i can also see that the integer "number" does not ever change nor is it set to any number.

PD: sorry if my writting is not good enough, my english is not very good yet.

but will my code work if i enter one single digit?

What happened when you tried it? You are basically asking us to write your program for you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.