15,918,889 members
See more:
who can i write a algorithm to the question
the question said:
```To write a C++ program to read five integer
elements into an array and find their sum ```

What I have tried:

I WRITE THE CODE OF THE QUESTION
```/****************************************************************************************************
Purpose : To write a C++ program to read five integer elements into an array and find their sum.
*****************************************************************************************************/
#include <iostream>
using namespace std;

int main()
{
int A[5];
int sum=0;
cout<<"Enter the array elements :"<<endl;
for(int i=0; i<5; i++)
{
cin>> A[i];
}
for(int i=0; i<5; i++)
{
sum = sum + A[i];
}
cout << "The sum of the elements is :" <<sum<<endl;
return 0;
}```
Posted
Updated 30-Jun-23 4:23am
v3
CPallini 3-May-21 6:18am
You don't need help. Your code, as it stands, compiles and runs fine.
AAisha Sultan Salim Al Kindi 3-May-21 7:33am
yes i knew the code it is correct but i want the explain and algorithm of the code
CPallini 3-May-21 7:38am
Nothing better then than you, the author of the code, can explain the implemented algorithm.
AAisha Sultan Salim Al Kindi 3-May-21 7:41am
I don't understand the code to write the algorithm
CPallini 3-May-21 7:44am
So it is not yours.
Start reading a tutorial on C++ (or C) loops and arrays. The code is simple, grasping it should be easy.

## Solution 3

#include <bits stdc++.h="">
using namespace std;
int main(){
int arr[5];int sum = 0;
for(int i = 0 ;i<5;i++){
cin>>arr[i];
sum+=arr[i]; //short and efficient code;
}
cout<

v2
Dave Kreskowiak 30-Jun-23 11:06am
Doing homework for someone is a really bad idea.

## Solution 2

Your code compiles, runs and produces a correct answer: so what more is necessary?

If what you have isn't enough, you need to go back to your exact assignment, read it again very carefully, and work out what exactly it expects you to hand in.

We can't do that for you!

AAisha Sultan Salim Al Kindi 3-May-21 7:09am
can you write an algorithm to the code I gave you
OriginalGriff 3-May-21 7:56am
"Loop though all elements, adding them together"?
AAisha Sultan Salim Al Kindi 3-May-21 8:30am
can you help me to write a code to this question
To write a C++ function which accepts your name
(string) as an input and print it in reverse order
without using a built in function.
OriginalGriff 3-May-21 8:50am
We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

If you are having problems getting started at all, then this may help:
https://www.codeproject.com/Articles/5282084/How-to-Write-Code-to-Solve-a-Problem-A-Beginners-G

But your attitude of "oh i don't have enough time to read ....." hasn't exactly enamoured you to people ...
AAisha Sultan Salim Al Kindi 3-May-21 13:28pm
I am sorry for the misunderstanding. I understood that this website gives the answer for the student and not his help. I'm sorry I didn't intend that