Modify the program to double each number in the vector. #include <iostream> #include <vector> using namespace std; int main()...

90.2K

Verified Solution

Question

Programming

Modify the program to double each number in the vector.

#include #include using namespace std;int main() {  const int N=8;  vector nums(N); // User numbers  int i=0; // Loop index  cout << \"\nEnter \" << N << \" numbers...\n\";  for (i = 0; i < N; ++i) {   cout << i+1 << \": \";   cin >> nums.at(i);  }  // Convert negatives to 0  for (i = 0; i < N; ++i) {   if (nums.at(i) < 0) {     nums.at(i) = 0;   }  }  // Print numbers  cout << \"\nNew numbers: \";  for (i = 0; i < N; ++i) {   cout << \" \" << nums.at(i);  }  cout << \"\n\";  return 0;}

Answer & Explanation Solved by verified expert
3.6 Ratings (631 Votes)
Hi According to the question program should be modified todouble each number in vector The given program already contains aloop that convers negative    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students