I have a problem in my C programm , my dumb brain cant figure out where the problem is ,Its about a programm that asks the user for a number then prints out the number of hundreds , tens , and ones
C programm wtf ?.???
whats the issue?
>no output listed
Some of us don't have time to rewrite your entire code OP. Give us example outputs.
similarly to scanf where you used &N, on printf you have to use &N, &x, etc.
stick to something easier like women's lit
nothing personnel, kid
First of all, maybe use more descriptive variable names. Secondly, why did you do this?
y = (N%100)/10; instead of just Y = (N%10);
Try this instead, bear in mind I'm writing this out on a phone.
Int num = 0;
Int hundreds, tens, ones;
While(num > 999 || num < 100)
{
Printf("Enter a 3 digit number: ");
Scanf("%d",&num);
}
ones = num%10;
num/=10;
tens = num%10;
num/=10;
hundreds = num
Printf("Hundreds: %d Tens: %d Ones: %d\n",hundreds,tens,ones);
return 0;
That isn't true at all, user. Who the fuck told you that?
Is the bait that there is no semicolon after the final statement?
you forgot ;
yeah thats not true in the slightest
even a buss driver or cashier can do this.
example 1023
1023 / 100 = 10.23 (int already rounds for you ,so you get x = 10)
then you do this 1023 - 10* 100 = 23
you have 23 left. now you check how many 10s reapeat this untill 1s
you are not supposed to use any modular operations here
Never write C again, please. Stick to Python.
>Never write C again, please. Stick to Python.
If he fails at this, he should just stay away from coding in general. Even python doesn't get much easier than this
You forgot a semicolon after return 0
You need to include to do any maths friend.
Also, read a style guide
christ that's ugly, clean it up bitch
Ampersands are for storing values in the memory allocated for the variable. You do need them to retrieve the variable's value from memory.
>y = (N%100)/10;
>Y = (N%10);
That's not the same thing you retard.
keep it up. I remember when I started (C was my first language) I ran into all kinds of stupid mistakes. Just try to generalize, and the program does the work for you
pic related is my approach, wrong order still but werks
>i have no idea what a pointer is, the post
>he can't see the problem just from looking at this code snippet
If you're too much of a brainlet to program why are you even replying to the thread?
>the problem is your variable names
If you're too much of a brainlet to program why are you even replying to the thread?
z=N%10;
>Ampersands are for storing values
No
>You do need them to retrieve the variable's value
No
Time to start over Jamal