+ 1
[Doubt] Can Anyone Pls. Explain Me How Range Overloading Works.What Happens When You Exceed An D.Type's Defined Range.Look👇👇
I Have Two C++ Codes Here.Thanks For Explaining Me The Their Outputs And Range Overloading Too.😊😊🙆 https://code.sololearn.com/cFf7qgi88hOH/?ref=app https://code.sololearn.com/cqeLzgST6DLT/?ref=app
8 Answers
+ 2
Char overloading code:
The type char is a 1byte value.
1 byte has 8 bits. With 8 bits you can store 256 natural numbers.
Each number stands for a symbol.
Here is a list:
https://www.ascii-code.com
The code prints all these values.
Int overloading code:
I modified the code for you to make the output clearer:
https://code.sololearn.com/cCKt8tx0zXuf/?ref=app
Let me know when you still have questions.
BTW: The while loop is infinite, because 0 is always < i. It starts with i=3 and gets incremented by 1 each loop.
Question about exceeding the range:
you get an overflow. It simply starts at the lowest value. And when you get an underflow you are at the highest possible value.
(Fun-)Fact: The Ariane-5 rocket made a 7 billion dollar firework because of an integer overflow.
+ 2
You Are Great Brother!!
High-five✋
+ 2
Hey Alex Can You Help Me on An another code pls. Thanks🙆
https://code.sololearn.com/cey92UK7Qx0c/?ref=app
+ 2
Why It Prints 11??
+ 2
Ohh!
+ 2
That'll Will take Some Part Of My Brain To Understand But Sure I will Manage It
Thanks Alex🙆
+ 1
the increment of the while loop happens at the end of a loop block.
Here is a breakdown of what happens in your code:
x=1
x<6? -> yes, start loop (condition)
x=1*1 = 1 (body)
x +=2 (increment)
>> x=3
3<6? -> yes, next loop (cond.)
x = 3*3 = 9 (body)
x += 2 (incr.)
>> x=11
11<6? -> no, end loop (cond)
print x
+ 1
I added some stuff to your code:
https://code.sololearn.com/cxd0BagAnSfC/?ref=app