Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
එක පැකේජ් එකයි මාසෙටම Unlimited Internet. තාමත් DATA CARD දාන්න සල්ලි වියදම් කරනවද? අඩුම මිලට අපෙන්.
sayuru bandara
Updated:
Tuesday at 12:30 PM
Ad icon
ඉන්ටර්නෙට් එකෙන් හරියටම සල්ලි හොයන්න සහ Success වෙන්න කැමතිද? 🚀 (E-Money & Success Stories)
siri sumana
Updated:
Saturday at 11:44 PM
Gemini AI PRO 18 months Offer
Hawaka
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
Education
C/C++ Coding challenges
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="Enigma_1" data-source="post: 7979643" data-attributes="member: 78173"><p>This thread is for C/C++ programming. </p><p> I’ll give you guyz an algorithm. Give me a C/C++ implementation of it. Here goes. Say I have a number 896235716. I need to validate this. Validation algorithm is like this.</p><p></p><p></p><p>From the <span style="color: Magenta"><strong>last</strong></span> digit you start extracting. Here the last digit is 6. So you take number 6. Then you don’t take 1 but you take 7. Likewise extraction goes on.</p><p></p><p> <span style="color: Red"><strong>8</strong> </span> 9 <span style="color: Red"><strong>6</strong></span> 2 <strong><span style="color: Red">3</span></strong> 5 <strong><span style="color: Red">7</span></strong> 1 <strong><span style="color: Red">6</span></strong> </p><p></p><p> 8 6 3 7 6 </p><p></p><p></p><p>multiply all the extracted digits by 2 </p><p> <span style="color: SeaGreen"><strong>8X2 = </strong></span>16</p><p><span style="color: SeaGreen"><strong>6X2 = </strong></span>12</p><p><span style="color: SeaGreen"><strong>3X2 = </strong></span>6</p><p><span style="color: SeaGreen"><strong>7X2 = </strong></span>14</p><p><span style="color: SeaGreen"><strong>6x2</strong></span> = 12</p><p></p><p>Then add all the digits together.</p><p> 1+6 + 1+2 + 6 + 1+4 + 1+2 = 24 </p><p></p><p>if the total is divisible by 10 then its a valid number.</p><p> <span style="color: Red">If 24mod10 !=0 then 896235716</span><span style="color: Red"> is not a valid number.</span></p><p>say total is 20. Then 20mod10 ==0 so the corresponding number is valid. </p><p></p><p> Please note that validation number (896235716 in this case) can be varying in length. Extraction always starts from the last digit. If you have doubts on this let me know.</p><p></p><p>mama example valid number ekak dennum.</p><p>5482742451 number eka valid number ekak. </p><p></p><p>kattiya try ekak danna. good luck.</p><p><img src="/styles/default/xenforo/smilies/default/rofl.gif" class="smilie" loading="lazy" alt=":rofl:" title="ROFL :rofl:" data-shortname=":rofl:" /><img src="/styles/default/xenforo/smilies/default/rofl.gif" class="smilie" loading="lazy" alt=":rofl:" title="ROFL :rofl:" data-shortname=":rofl:" /><img src="/styles/default/xenforo/smilies/default/rofl.gif" class="smilie" loading="lazy" alt=":rofl:" title="ROFL :rofl:" data-shortname=":rofl:" /><img src="/styles/default/xenforo/smilies/default/rofl.gif" class="smilie" loading="lazy" alt=":rofl:" title="ROFL :rofl:" data-shortname=":rofl:" /><img src="/styles/default/xenforo/smilies/default/rofl.gif" class="smilie" loading="lazy" alt=":rofl:" title="ROFL :rofl:" data-shortname=":rofl:" /><img src="/styles/default/xenforo/smilies/default/rofl.gif" class="smilie" loading="lazy" alt=":rofl:" title="ROFL :rofl:" data-shortname=":rofl:" /></p></blockquote><p></p>
[QUOTE="Enigma_1, post: 7979643, member: 78173"] This thread is for C/C++ programming. I’ll give you guyz an algorithm. Give me a C/C++ implementation of it. Here goes. Say I have a number 896235716. I need to validate this. Validation algorithm is like this. From the [COLOR=Magenta][B]last[/B][/COLOR] digit you start extracting. Here the last digit is 6. So you take number 6. Then you don’t take 1 but you take 7. Likewise extraction goes on. [COLOR=Red][B]8[/B] [/COLOR] 9 [COLOR=Red][B]6[/B][/COLOR] 2 [B][COLOR=Red]3[/COLOR][/B] 5 [B][COLOR=Red]7[/COLOR][/B] 1 [B][COLOR=Red]6[/COLOR][/B] 8 6 3 7 6 multiply all the extracted digits by 2 [COLOR=SeaGreen][B]8X2 = [/B][/COLOR]16 [COLOR=SeaGreen][B]6X2 = [/B][/COLOR]12 [COLOR=SeaGreen][B]3X2 = [/B][/COLOR]6 [COLOR=SeaGreen][B]7X2 = [/B][/COLOR]14 [COLOR=SeaGreen][B]6x2[/B][/COLOR] = 12 Then add all the digits together. 1+6 + 1+2 + 6 + 1+4 + 1+2 = 24 if the total is divisible by 10 then its a valid number. [COLOR=Red]If 24mod10 !=0 then 896235716[/COLOR][COLOR=Red] is not a valid number.[/COLOR] say total is 20. Then 20mod10 ==0 so the corresponding number is valid. Please note that validation number (896235716 in this case) can be varying in length. Extraction always starts from the last digit. If you have doubts on this let me know. mama example valid number ekak dennum. 5482742451 number eka valid number ekak. kattiya try ekak danna. good luck. :rofl::rofl::rofl::rofl::rofl::rofl: [/QUOTE]
Insert quotes…
Verification
Nawa warak dahaya keeyada? (Namaya wadi kireema dahaya)
Post reply
Top
Bottom