Open study

is now brainly

With Brainly you can:

  • Get homework help from millions of students and moderators
  • Learn how to solve problems with step-by-step explanations
  • Share your knowledge and earn points by helping other students
  • Learn anywhere, anytime with the Brainly app!

A community for students.

i have a program assignment. this is the problem: Input a number and store the integers of the number to the elements of the array. print the integers and the sum of the integers from the array. my program is wrong :( can someone help me please

Computer Science
See more answers at brainly.com
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

Join Brainly to access

this expert answer

SEE EXPERT ANSWER

To see the expert answer you'll need to create a free account at Brainly

what programming language are you using? so at the moment what are you doing? using an array to store the numbers as the user enters them? then summing and outputting them after the user is done?
C++
this is my prog: #include #include using namespace std; int main(int argc, char *argv[]) { int x[0],sum=0,a,num,n; cout<<"How many number do you wish to add: "; cin>>a; cout<<"Enter the numbers: "; cin>>x[a]; for(int b=0;b<;b++) { cin>>x[b]; sum+=x[b]; cout<<"The sum of your numbers: "<

Not the answer you are looking for?

Search for more explanations.

Ask your own question

Other answers:

do you have any limitations on what you're allowed to do? for example are you allowed to use a list? or much you use an array?
no
i see so you are just having issues with creating the array int* array; int size; cout << "How many numbers would you like to enter?" << endl; cin >> size; and then when you want to create it array = new int[size]; and when you're done make sure you give back the memory delete [] array;
wait ill try that
done. here is my new program but how can i repeat the question "ENTER THE NUMBER" depending on the number u want to input?
#include #include using namespace std; int main(int argc, char *argv[]) { int array[0],sum=0; int size; cout << "How many numbers would you like to enter?"; cin >> size; cout<<"Enter your numbers "; for(int x=0;x>array[x]; sum+=array[x]; } cout<<"The sum is "<
do you mean ask them to enter a number each time? you could output the statement in the for loop
done thank you !
here is my another problem and LAST poblem: Write a program that will search for the largest and smallest value in array of integers of length 10.
here is my program: #include #include using namespace std; int main(int argc, char *argv[]) { float x[10],largest,smallest; cout<<"Enter a number "; cin>>x[0]; largest=x[0]; for(int a=0;a<10;a++) { cin>>x[a]; if(x[a]>largest) largest=x[a]; cout<<"The largest number is "<
#include #include using namespace std; int main(int argc, char *argv[]) { int* array; int sum=0; int size; cout << "How many numbers would you like to enter?"; cin >> size; cout<<"Enter your numbers "; array = new int[size]; // init the array to for(int x=0;x>array[x]; sum+=array[x]; } cout<<"The sum is "<
oooops sorry ! thats wrong.
here is the real program that i made: #include #include using namespace std; int main(int argc, char *argv[]) { float x[10],largest,smallest; cout<<"Enter a number "; cin>>x[0]; largest=x[0]; for(int a=0;a<10;a++) { cin>>x[a]; if(x[a]>largest) largest=x[a]; cout<<"The largest number is "<
ok i've looked at the code, where are you having problems ?
it doesnt run :(
you're missing some curly brackets { after the if(x[a]>largest) and } after cout<<"The smallest number is "<
actually im doing trial and error. :) but i cant print the largest and smallest number that entered
im done ! lol :D i did it
good work =)
but how can i repeat again "ENTER THE NUMBER" ??
here is my final program: #include #include using namespace std; int main(int argc, char *argv[]) { float x[10],largest,smallest; cout<<"Enter a number "; cin>>x[0]; largest=x[0]; for(int a=1;a<10;a++) { cin>>x[a]; if(x[a]>largest) largest=x[a]; if(x[a]
put cout<<"Enter a number "; into the for loop
just it? or together with the cin>>x[0]; largest=x[0];??
i didnt work. well actually it run but it double the number
like for(int a=1;a<10;a++) { cout<<"Enter a number "; cin>>x[a]; if(x[a]>largest) largest=x[a]; if(x[a]
the largest number didn't work.
that's strange from the code i can see it should have, one sec i'll compile it and have a look
the code you sent before is working fine =\
done :D
i did this: for(int a=0;a<10;a++) { cout<<"Enter a number "; largest=x[0]; cin>>x[a]; if(x[a]>largest) largest=x[a]; if(x[a]
do have any facebook account? i will add u so that when i have another problem. i can ask u about it.
just ask on here that way if i'm not around anyone can help =)
ok sure. wait i saw this problem here on my book. it says " Write a program that will print the seven positioned elements in an array of 10 floating numbers."
that confused me. what would be the program look like ?
ndani14 helps everybody...how kind he is,don't you think so?he helped me a lot:))
yup i think he is really kind and helpful. God Bless him. Thank you again ndani14!
so you have an array of 10 floats and it wants to know how you would access the seventh element? eg. float myFloats[10]; myFloats[x]; // what should x be?
what does the "even positioned element" mean? the elements like: 2,4,6,8,10 elements?
the numbers that u input to the 2,4,6,8,10th element will print out ?? is that it ?
almost except arrays begin their indexing at 0 so the 1st element is 0, 2nd is 1 and so on

Not the answer you are looking for?

Search for more explanations.

Ask your own question