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
Colombo
RidhMathraa ’26 🎶✨
Tmadhusanka
Updated:
Yesterday at 11:58 PM
Ad icon
Colombo
PXN V10 Pro Direct Drive Racing Wheel (Under Warranty)
Abdur Rahman
Updated:
Yesterday at 10:23 PM
Ad icon
USDT ණය සේවාව - USDT Loan Service
පුරවැසියා
Updated:
Yesterday at 4:54 PM
Ad icon
🎮 INDIAN PSN GIFT CARDS AVAILABLE NOW! 🎮
madukaperera
Updated:
Tuesday at 12:57 PM
🚀 Google AI PRO – 18 Months | Rs. 850 Only
lkkolla
Updated:
Monday at 4:56 PM
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Help
Need Help in 'C'
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="x-pert" data-source="post: 3978146" data-attributes="member: 837"><p>PM ekata answer eka methana dennam machang ooni kenekta balaaganna and mama waradi nam danna kenekta hadanna </p><p></p><p>Problem of the below: </p><p></p><p>[CODE]#include <stdio.h></p><p># include <string.h></p><p></p><p>main()</p><p></p><p>{</p><p></p><p>int i,m,n,count;</p><p>char str[10],rev_str[10];</p><p></p><p>printf("Enter a String :");</p><p>gets(str);</p><p></p><p>for(i=0;str[i]!='\0';i++)</p><p>{</p><p></p><p>}</p><p></p><p>m=i;</p><p>n=i;</p><p>for(i;i>0;i--)</p><p> {</p><p></p><p> rev_str[n-i]=str[i]; </p><p></p><p>[B][COLOR=DarkGreen]// Logic is a little bit wrong machang as I can see. </p><p>// Let's go in to the loop</p><p>// step 1: for i; i>0; i-- </p><p>// Let's say the array size is 6. So condition, i > 0 satisfies.</p><p>// Then i-- = 5</p><p>// Then, rev_str[6-5] = str[i] Which means, rev_str[1] = str[5]</p><p></p><p>//Second loop</p><p>// now i = 5. </p><p>// So rev_str[6-4] = str[4] Which means, rev_str[2] = str[4] </p><p></p><p>// and so on...</p><p></p><p>// So what happens to the first item of the array? (rev_str[0]?)[/COLOR][/B] </p><p></p><p></p><p> }</p><p></p><p></p><p>printf("new: %s",rev_str);</p><p></p><p>}</p><p></p><p></p><p>[/CODE]</p></blockquote><p></p>
[QUOTE="x-pert, post: 3978146, member: 837"] PM ekata answer eka methana dennam machang ooni kenekta balaaganna and mama waradi nam danna kenekta hadanna Problem of the below: [CODE]#include <stdio.h> # include <string.h> main() { int i,m,n,count; char str[10],rev_str[10]; printf("Enter a String :"); gets(str); for(i=0;str[i]!='\0';i++) { } m=i; n=i; for(i;i>0;i--) { rev_str[n-i]=str[i]; [B][COLOR=DarkGreen]// Logic is a little bit wrong machang as I can see. // Let's go in to the loop // step 1: for i; i>0; i-- // Let's say the array size is 6. So condition, i > 0 satisfies. // Then i-- = 5 // Then, rev_str[6-5] = str[i] Which means, rev_str[1] = str[5] //Second loop // now i = 5. // So rev_str[6-4] = str[4] Which means, rev_str[2] = str[4] // and so on... // So what happens to the first item of the array? (rev_str[0]?)[/COLOR][/B] } printf("new: %s",rev_str); } [/CODE] [/QUOTE]
Insert quotes…
Verification
Winadiyakata thappara keeyak tibeda?
Post reply
Top
Bottom