Question

I need help with this c++ code. This is my first computer science course. I have...

I need help with this c++ code. This is my first computer science course. I have not learned arrays but I am learning vectors. I am also required to write this code without do loops or any other form of advanced coding technique. Please help me figure out this code using the basic coding techniques that you would find in an introduction to cs. Thank you for your help, I don't even know where to start :)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the code below:::

#include <iostream>
using namespace std;
int main( )
{
   //first number is total number of element
   int numberOfElem;
   //get the number
   cin>>numberOfElem;

   //creat list of number as array
   int list[numberOfElem];

   //store user input of array
   for(int i=0;i<numberOfElem;i++){
       cin>>list[i];
   }

   int lowerBound,upperBound;

   //get last two bound value
   cin>>lowerBound>>upperBound;

   //loop for array
   for(int i=0;i<numberOfElem;i++){
       //if element in range print it
       if(list[i]>=lowerBound && list[i]<=upperBound){
           cout<<list[i]<<" ";
       }
   }


   return 0;
}

mainProgram.c 1 #include <iostream> 2using namespace std; 3int main( ) main.cpp //first number is total number of element int

output:
Console <terminated> CPP Workspace. 5 25 51 0 200 33 0 50 25 0 33

Add a comment
Know the answer?
Add Answer to:
I need help with this c++ code. This is my first computer science course. I have...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT