Reverse An Integer Number | C Programming Example

  Рет қаралды 14,616

Portfolio Courses

Portfolio Courses

Күн бұрын

Пікірлер: 33
@tweetybird155
@tweetybird155 2 жыл бұрын
SUCH A LIFE SAVER THANK YOU FOR THIS!
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You're very welcome! 😀
@tahmidanzum151
@tahmidanzum151 2 жыл бұрын
Well explanation, thank you
@PortfolioCourses
@PortfolioCourses 2 жыл бұрын
You’re welcome Tahmid! :-)
@bkarthik455
@bkarthik455 10 ай бұрын
What happens when last digit takens as zero Ex:- if i want to reverse a num 7890 What will the output I run the program of 7890 I got the output as 987 but it doesn't show 0 at starting in reverse of a number. Could pls explain this.
@JoãoPedroTrindadeMelo
@JoãoPedroTrindadeMelo 4 күн бұрын
zero at left doesn't count
@cobblie8789
@cobblie8789 Жыл бұрын
Is there any way to do this without using a loop?
@kartikthakur6931
@kartikthakur6931 9 ай бұрын
what will this program do at 1111111113, as it's reversal will be out of int -datatype value limits.
@AcunPearce
@AcunPearce 6 ай бұрын
you can use long data type
@akshaypundir8333
@akshaypundir8333 Жыл бұрын
how to prevent signed integer overflow
@PortfolioCourses
@PortfolioCourses Жыл бұрын
You might find this stackoverflow answer helpful: stackoverflow.com/a/62943541. :-)
@agm3194
@agm3194 Жыл бұрын
Which code editor is it?
@PortfolioCourses
@PortfolioCourses Жыл бұрын
In this video I am using Xcode on a Mac. :-)
@ingénieureinformatique-h5y
@ingénieureinformatique-h5y 2 ай бұрын
Thanks 😅
@mccauleybacalla2228
@mccauleybacalla2228 4 ай бұрын
thanks!
@lumiplex404
@lumiplex404 Жыл бұрын
Try reversing a negative number with this programme :)
@PortfolioCourses
@PortfolioCourses Жыл бұрын
It works with negative numbers. :-)
@lumiplex404
@lumiplex404 Жыл бұрын
@@PortfolioCourses Try it, it will throw the code into an infinite loop because negative numbers don't return 0 after dividing it again and again. Only 1 minus(-) can change the whole game. Maybe thats why my maths teacher told me to be careful if the problem contains minus 😆
@PortfolioCourses
@PortfolioCourses Жыл бұрын
@@lumiplex404 No that's incorrect, it works. Did you try it? I tried using negative numbers before I created the video, and then again after your comment, and it works. I've now tried it for a 3rd time on 3 different compilers, and it still works. 🙂
@lumiplex404
@lumiplex404 Жыл бұрын
@@PortfolioCourses Even in the leetcode solutions, they avoided negative numbers in the following way if x < 0: return False
@PortfolioCourses
@PortfolioCourses Жыл бұрын
@@lumiplex404 I don't understand what leetcode has to do with this solution being correct or incorrect with negative integers. Did you try it yet? The code is available here: github.com/portfoliocourses/c-example-code/blob/main/reverse_integer.c
@mxhell3867
@mxhell3867 Жыл бұрын
How to reverse an integer with leading zeroes or only zeroes? Like : Input: 009921 Ouput: 129900 Input: 000 Output: 000 Thanks in advance!
@PortfolioCourses
@PortfolioCourses Жыл бұрын
How is the integer stored in this case? As a string? If so we could just reverse the string. If it's not stored as a string, then how do we know how many leading zeros there are?
@lumiplex404
@lumiplex404 Жыл бұрын
the leading zeros don't have a value so thee programme wouldn't count them or know how many zeros were used there.
@mxhell3867
@mxhell3867 Жыл бұрын
@@PortfolioCourses sorry for late reply, yeah we have to work with strings otherwise we won't even know if user put any zeroes..
@PortfolioCourses
@PortfolioCourses Жыл бұрын
@@mxhell3867 Ah OK, well if it's a string, and it's a positive integer for sure, then you could technically just reverse the string itself: kzbin.info/www/bejne/hqW2eZalqpWKf9U. 🙂 If it could be a negative number, then you could check if the first char in the string is '-', and if it is, reverse the portion of the string after the '-' only.
Calculate The Factorial Of A Number | Python Example
4:46
Portfolio Courses
Рет қаралды 669
Check If A String Is A Palindrome | C Programming Example
10:56
Portfolio Courses
Рет қаралды 44 М.
Reverse An Array | C Programming Example
7:34
Portfolio Courses
Рет қаралды 38 М.
Reverse A File | C Programming Example
8:52
Portfolio Courses
Рет қаралды 7 М.
Count Even And Odd Numbers In An Array | C Programming Example
6:00
Portfolio Courses
Рет қаралды 1,3 М.
Reverse The Words In A String | C Programming Example
6:18
Portfolio Courses
Рет қаралды 28 М.
How to Stop Intrusive Voices | Dr. Ethan Kross & Dr. Andrew Huberman
13:41
Huberman Lab Clips
Рет қаралды 1,3 М.
Convert binary to decimal | C Programming Example
9:06
Portfolio Courses
Рет қаралды 14 М.
Selection Sort | C Programming Example
8:00
Portfolio Courses
Рет қаралды 65 М.