Free webinar! How to Make Generative AI Work for You
Get my free ticket+ 2
Ravi
Here it is but you should try first.
n is global variable.
https://code.sololearn.com/c6t3gMxo09cA/?ref=app
+ 5
First show your attempt...
+ 5
Ravi if u are a beginner
Start learning
https://www.sololearn.com/discuss/333866/?ref=app
https://www.sololearn.com/discuss/1316935/?ref=app
+ 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
+ 2
Ravi
Do you mean sth like my code?
https://code.sololearn.com/cs56LkD3o9u2/?ref=app
+ 2
Nick
That's
3 * 3 + 4 * 4 + 5 * 5 = 50
+ 1
Nick
It is actually square.
I've just edited
+ 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
+ 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;
}
0
Is it just me or the part 32+42+52 = 50 looks kinda weird
0
Ravi
Have you figured out yet?
0
Not yet Nick
I'm still working.
Please tell code if you could
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
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.
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
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?
- 1
Please someone tell, I'm beginner
- 1
Time Is Money
Please you help, this is my college assignment and I have to submit by tonight.