Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2
Ravi Here it is but you should try first. n is global variable. https://code.sololearn.com/c6t3gMxo09cA/?ref=app
23rd Sep 2021, 6:49 AM
A͢J
A͢J - avatar
+ 5
First show your attempt...
22nd Sep 2021, 1:37 PM
Pariket Thakur
Pariket Thakur - avatar
22nd Sep 2021, 1:43 PM
Pariket Thakur
Pariket Thakur - avatar
+ 3
Martin Taylor Thank you for opening my eyes 🙏 But the reality is very harsh in case of online classes, we are supposed to learn by ourselves with very less support from instructors of College. With this, they evaluate us regularly from past pre defined tests papers
22nd Sep 2021, 3:41 PM
Ravi
22nd Sep 2021, 5:42 PM
mesarthim
mesarthim - avatar
+ 2
Nick That's 3 * 3 + 4 * 4 + 5 * 5 = 50
22nd Sep 2021, 7:00 PM
A͢J
A͢J - avatar
+ 1
Nick It is actually square. I've just edited
22nd Sep 2021, 5:10 PM
Ravi
+ 1
A͢J - S͟o͟l͟o͟H͟e͟l͟p͟e͟r͟ Oh my bad, it was hours ago before he edited, didn't make sense to me until he turned the 2's into components
22nd Sep 2021, 7:02 PM
Tim
Tim - avatar
+ 1
Ravi This is very simple program. Just skip those numbers which doesn't exist in range so for this you can use continue like this: int findSum (int arr[], int si, int ei) { int sum = 0; for(int i = 0; i < n; i++) { //skip to add in calculation which is not in range if (i < si || i > ei) continue; sum += arr[i] * arr[i]; } return sum; }
22nd Sep 2021, 7:35 PM
A͢J
A͢J - avatar
0
Is it just me or the part 32+42+52 = 50 looks kinda weird
22nd Sep 2021, 4:34 PM
Tim
Tim - avatar
0
Ravi Have you figured out yet?
22nd Sep 2021, 5:16 PM
Tim
Tim - avatar
0
Not yet Nick I'm still working. Please tell code if you could
22nd Sep 2021, 5:19 PM
Ravi
0
Ravi You're given the input: 5 1 2 3 4 5 2 4 It's kinda confusing to see it that way, so I'd separate it like this: 5 | 1 2 3 4 5 | 2 4 Let me rewrite the explanation for you: 5 represents the size of the array followed by the array, then the starting index 2 (inclusive), and the ending index 4 (inclusive), calculate the square between them and sum them up
22nd Sep 2021, 5:26 PM
Tim
Tim - avatar
0
A͢J - S͟o͟l͟o͟H͟e͟l͟p͟e͟r͟ Here in your code n is undeclared. Please can you provide complete code.
23rd Sep 2021, 4:28 AM
Ravi
0
Ravi It seems your question appears to be an assignment. Please show us your attempt and use the 8 rules to get help from the community. https://www.sololearn.com/Blog/38/8-simple-rules-to-get-help-from-the-community *can be a code coach solution which is meant for you to do to help you establish your skills abilities and where you need to learn... not the community *one issued by a school or other institution *one issued or created by another platform *one that appears to be in the form of a challenge that was created by you or somewhere else. Your question has been reviewed and will be marked for deletion. https://www.sololearn.com/Discuss/1316935/?ref=app
23rd Sep 2021, 9:04 PM
BroFar
BroFar - avatar
0
BroFar Yes , it was my assignment. But I had no clue to start it, so I posted here to get some sort of help. Now,. please tell what to do in this question to remove mfd tag? shall I modify the question now?
24th Sep 2021, 2:46 AM
Ravi
- 1
Please someone tell, I'm beginner
22nd Sep 2021, 1:42 PM
Ravi
- 1
Time Is Money Please you help, this is my college assignment and I have to submit by tonight.
22nd Sep 2021, 1:49 PM
Ravi