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
  • Hello! I desperately need help with this project for my computer science class c++. Please let...

    Hello! I desperately need help with this project for my computer science class c++. Please let me know if any clarification or additional information is needed. Compliance with the outlined project requirements is crucial. Thank you!!! and I'll rate you up too thank you! 1) Program must implement a minimum of 3 classes (which we will learn about in Ch.13). 2) You should make use of plenty of the concepts that we have learned or are learning in class (for...

  • Hello, I am currently in computer science 112 and this is my first course ever in...

    Hello, I am currently in computer science 112 and this is my first course ever in this field. I am currently a nursing major just satisfying a tech credit. Can you explain to me exactly what the language of C++ is ?

  • This is for my Computer Programming class using Visual Studio C++ This is a home work...

    This is for my Computer Programming class using Visual Studio C++ This is a home work assignment and is for a grade so answer seriously and if you don't know know or unsure don't answer I need the coding so i can copy and paste and need a screen shot of the result i can copy as well Thank You. P1 – Merge two sorter arrays (80 points) (a) Write a function that receive two sorted arrays of integers and...

  • I need help with this problem for computer science, have had difficulties figuring out for loops,...

    I need help with this problem for computer science, have had difficulties figuring out for loops, please help, sorry the pyramid is kinda messed up but it's supposed to be a pyramid Prog3d: Use for loops to construct a program that displays a pyramid of $ on the screen. The pyramid should look like this: [4] $ $$$ $$$$$ $$$$$$$ $$$$$$$$$ Note: There is no space in front of the first $ of last row. The above example shows only...

  • Can anyone help me with my homework assigment. Computer Science - Database Conceptes and Applications I...

    Can anyone help me with my homework assigment. Computer Science - Database Conceptes and Applications I added an image of instuctions on how the assingment needs to be done. Thank you for your efforts.

  • "Write a class that represents a course at Juniata. A course has a department (ex. CS,...

    "Write a class that represents a course at Juniata. A course has a department (ex. CS, IT, PY, BI), a number (ex. 110, 240, 356), a name (ex. Computer Science 1), and a number of credits. Write a test driver just to make sure your class works. I recommend just instantiating a few courses and displaying them using the __str__ method. If you want to go a little farther, store a few courses in a list and loop through them...

  • Hello I need help turning my code into a GUI applicaiton please. What I have for...

    Hello I need help turning my code into a GUI applicaiton please. What I have for code and the requirements are below. Please please help, I will be so greateful. This is my last assignment of my school and I'm just so burnt out mentally that I don't know where to start and my teacher is always to busy to help. Thank you so so so much! -----Code------ private void CalculateSC(ActionEvent event) { if(amount < 10){ chargeAmount = 1; }else...

  • Hi I need some help with this I just need the code and the collection name...

    Hi I need some help with this I just need the code and the collection name is research only the code I dont need any screenshots of the output. it should be for companies.json using the research collection as like this db.research.aggregate({}) but I don't know how to do the rest. This is the database but it is hard to paste it all so I will paste some and it should be create. Please I need this to be done...

  • Having trouble writing this code in C++. It asks to convert the for loops. I tried...

    Having trouble writing this code in C++. It asks to convert the for loops. I tried it myself but I don't think I am doing it right, please help fix. Edit: this is the whole question...It just asks to make the following changes to the for loops.. Question: Write and "convert" the i and j for loops as follows: * i must start at ilow, * i's for loop will terminate at ihigh, * j must start at jlow, *...

  • I am needing to code a coffee mug in OpenGL using c++. I have found the coding for a tea kettle b...

    I am needing to code a coffee mug in OpenGL using c++. I have found the coding for a tea kettle but we have been told we cannot use a tea kettle. I have attached a photo for reference. Thank you for any help you can provide!

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