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
Pure VPN - Up to 27 Months
vgp
Updated:
Today at 8:10 AM
එක පැකේජ් එකයි මාසෙටම 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
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Help
Write a C++ Program...
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="viraj_slk" data-source="post: 7372505" data-attributes="member: 51932"><p><span style="font-size: 12px">Here ! the code is right in front of you bro! why are u asking for more? you only have to correct the sytaxes according to C++ now. don't expect me to go through C++ syntaxs now and do it. it's ur job. <img src="/styles/default/xenforo/smilies/default/happy.gif" class="smilie" loading="lazy" alt=":)" title="Happy :)" data-shortname=":)" /></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">again the code is:</span></p><p><span style="font-size: 12px">[CODE]</span></p><p><span style="font-size: 12px">arr[] = {1, 2, 3, 4, 5} // or whatever other numbers u want. this is our original array.</span></p><p><span style="font-size: 12px">new_arr[]; // new array we are going to build</span></p><p><span style="font-size: 12px">int p; // the new position for each element in array</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">for(i= 0; i < n; i++){</span></p><p><span style="font-size: 12px"> p = (i + x)%n; // remember n is the number of values in array & x is user input value</span></p><p><span style="font-size: 12px"> </span></p><p><span style="font-size: 12px"> new_arr[p] = arr[i]; </span></p><p><span style="font-size: 12px">} </span></p><p><span style="font-size: 12px">[/CODE]</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">now 'new_arr' array contains the shifted numbers. This is the code. Use ur syntaxes to write it in whatever language u want.</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">to answer ur questions:</span></p><p><span style="font-size: 12px">no u don't have to give a size to the array. but if you want, give it the same size as the original. it's going to contain the same number of elements any way. </span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px">use the for loop to fill the new array using the formula inside it that I described to you in the previous post.</span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p><p><span style="font-size: 12px"></span></p></blockquote><p></p>
[QUOTE="viraj_slk, post: 7372505, member: 51932"] [SIZE="3"]Here ! the code is right in front of you bro! why are u asking for more? you only have to correct the sytaxes according to C++ now. don't expect me to go through C++ syntaxs now and do it. it's ur job. :) again the code is: [CODE] arr[] = {1, 2, 3, 4, 5} // or whatever other numbers u want. this is our original array. new_arr[]; // new array we are going to build int p; // the new position for each element in array for(i= 0; i < n; i++){ p = (i + x)%n; // remember n is the number of values in array & x is user input value new_arr[p] = arr[i]; } [/CODE] now 'new_arr' array contains the shifted numbers. This is the code. Use ur syntaxes to write it in whatever language u want. to answer ur questions: no u don't have to give a size to the array. but if you want, give it the same size as the original. it's going to contain the same number of elements any way. use the for loop to fill the new array using the formula inside it that I described to you in the previous post. [/SIZE] [/QUOTE]
Insert quotes…
Verification
Nawa warak dahaya keeyada? (Namaya wadi kireema dahaya)
Post reply
Top
Bottom