0

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);
}

4
Contributors
4
Replies
5
Views
10 Years
Discussion Span
Last Post by WaltP
0

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.

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.