Ask your own question, for FREE!
Computer Science 14 Online
OpenStudy (christos):

1) Write a program and do the following each in a separate statement: a) Declare an array called “Num” with 15 integers. b) Initialize all the items of the array to 0. c) Change all the items of the array with an ODD position to -1. d) Ask the user to enter values only at the items with an EVEN position. e) Display the position along with the item, for all items in the array, each in a separate line.

OpenStudy (anonymous):

So: a) int Num[15]; b) for(int k=0; k<15; k++) { Num[k]=0; } c) for(int k=0; k<8; k++) { Num[2k+1]=-1; } d) int input; cout<<"Enter calues only at an even position: "<<endl; cin>>input This should be enough help, I will leave the last one to you.

OpenStudy (christos):

But how do I actually print the (a) qith C++ ? @jlvm

OpenStudy (anonymous):

I do not understand your question. First, which part of the question are you referring to? Second, b clear about what you want to know? Did you mean how to print the ith element in the array?

OpenStudy (christos):

How to print the Num[15] - meaning all the numbers of the said array ?

OpenStudy (anonymous):

Look at part (b).

OpenStudy (anonymous):

Do you know what that is called?

OpenStudy (christos):

It is my first time working with arrays so unfortunately I can't tell :/

OpenStudy (anonymous):

Nothing to do with arrays. It's a loop.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!