r/code • • Oct 02 '25
Help Please Can anyone point out my mistake
Question: WAP to print reverse of the given number....
8
Upvotes
r/code • • Oct 02 '25
Question: WAP to print reverse of the given number....
36
u/squartino Oct 02 '25
Your first mistake is making photos by smartphone
13
u/nwbrown Oct 02 '25
This is not how you ask for help.
Don't give a screenshot of your code, post the code.
Don't just ask for people to point out your mistake, state what you expect to happen and what is happening instead.
9
u/gromaxgg Oct 04 '25
Bro getting hate more than help lmao
13
u/SupermarketNo3265 Oct 02 '25
Does it physically pain you to use a keyboard?
No? Then name your variables something other than a single letter, unless it's a loop counter.
6
u/SnooChipmunks547 Coder Oct 02 '25
First mistake, and where I gave up reading, if N is not divisible by 10, you create an infinite loop.
Your second mistake is thinking variables should be single letters, you’ll run out of those quick enough.
1
u/Cozy_04 Oct 02 '25
Not sure what you're specifically asking about: compilation error, logical error, etc.? But I think the pow function expects two doubles and not ints. Read the output of your compiler and see what it tells you and maybe post it here
1
u/Manque2Preuve Oct 02 '25
Im not sure but the whiles loops look weird, maybe the problem comes from there. also put some \n at the end of your printf the result will be cleaner.
you can try your code without the scanf but a given number to see if it work then add the scanf (scanf is not a sure way you risk an buffer overflow).
And last thing please make a clean code 💀
1
u/GrumpMadillo Oct 02 '25
The time you saved by not having to type longer variable names is all lost on reading the code you write
1
u/OM3X4 Oct 02 '25
I think the first loop won't end because no division results in zero unless the numerator is zero
1
u/dvidsnpi Oct 02 '25
pow() is supposed to work with doubles, you are truncating ints I guess just by eyeballing it?
see how its readable even without comments? avoid single letter variables where possible!
1
u/AmazingGabriel16 Oct 02 '25
Unsure as I don't use C etc, but you should try to make the variables have actual meaning instead of just characters of the alphabet, it will save you the headache of trying to figure things out in the future.
1
u/kohuept Oct 02 '25
Try r/C_Programming instead, and learn how to copy paste code into a codeblock on reddit
1
u/lavahot Oct 02 '25
Why do you dox yourself?
1
u/Tittytickler Oct 02 '25
Like everyone else has said, you need to name your variables. Second, you need to leave comments in your code describing what you're doing. 3rd, your while loop is infinite. There are no division operations that result in 0, unless the numerator is 0.
1
u/DrGrapeist Oct 02 '25
The only thing I can see that is wrong is 400 becomes 4
1
u/[deleted] Oct 02 '25
Using C is the first mistake
1
u/Front-Buyer3534 Oct 04 '25
Take that 100% working code. It's good for your homework
1
u/modd0c Oct 04 '25
include <stdio.h>
int main() { int n, reverse = 0;
}
1
u/SkyChess2610 Oct 04 '25
my project
1
u/No_Quail9416 Oct 05 '25
Edgecase: n ends in zero (results in missing 1 digit for b) Edgecase: if b is zero 100 is 1
There’s probably other errors if you can provide some input / output
For other readers ig: a = save n b = digits in input (doesn’t work due to above) c = reverse answer ld = last digit e = 10 ^ b for digit (doesn’t work) n = input number
1
u/HorrorGeologist3963 Oct 26 '25
First mistake I see is you don’t write the code. Name the function, name the variables, make your thinking apparent. Self documented code is practice that will help you and anyone involved with your code.
-2
u/[deleted] Oct 02 '25
Are you wanting someone to fix your homework without telling us what the problem is?
Idiotic variable names, by the way.
0
u/[deleted] Oct 02 '25
[deleted] — view deleted comment
1
u/[deleted] Oct 02 '25
[removed] — view removed comment