Hey Jow Forums it's my first time posting here so no bully.
Im a C newbie and I'm doing exercices to improve, I don't know if it's supposed to be this complicated or Im just too low IQ to be able to study computer science.
I have to write a function (With no pointers, printf or arrays allowed) whose execution will give me :
you can have ABCD as integers and printing '0' + integer Or you can have it as single number and printing n/1000, (n/100)%10, (n/10)%100, n%10 (with ^). This will simplify the logic a lot.
Angel Collins
This either seem overly complicated or im not smart enough to see the genius behind it
Ryan Sanchez
aChar = i + '0';
instead
Dominic Peterson
It seems a lot of people use the modulo yet I dont seem to follow how it is used in this case
Gabriel Powell
To get specific digit from decimal denotation. Let's say you have n=333633 and want to get the third lowest digit (6), n/100 == 3336, 3336%10 == 6 so to get x-th digit the formula would be ( n / 10^(x-1) ) % 10
also mistake in my comment, there should be (n/10)%10
Adrian Diaz
for( int i = 0; i
Ryder Moore
are you sure that theres not an error in the exercise? seems weird to make one of them off like that
Kayden Wilson
Wow that's pretty cool ! But in my code I used char instead of int so I don't know if it would work. Still it seems like a very useful trick thank you so much
Adrian Thomas
I have wondered that myself but It is the way its written in it.