1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Rufina [12.5K]
3 years ago
5

Write a program that: Takes the list lotsOfNumbers and uses a loop to find the sum of all of the odd numbers in the list (hint:

use Mod). Displays the sum.
Computers and Technology
1 answer:
Alika [10]3 years ago
5 0

Answer:

Following are the code to this question:

#include <iostream>//defining header file

using namespace std;

int main()//defining main method

{

int x[]={2,3,4,6,7,8,9,1,11,12};//defining 1-D array and assign value

int i,sum=0;//defining integer variable

for(i=0;i<10;i++)//defining loop for count value

{

   if(x[i]%2==1)//defining if block to check odd value

   {

       sum=sum+x[i];//add value in sum variable

   }

}

cout<<sum;//print sum

return 0;

}

Output:

31

Explanation:

In the above-given program, an integer array "x" is declared that holds some integer values, and in the next line two integer variable "i and sum" is defined which is used to calculate the value.

In the next line, a for loop is declared, that counts all array value, and it uses the if block to check the odd value and add all the value into the sum variable.

You might be interested in
Which one of the following is the correct code snippet for calculating the largest value in an integer array list aList?
vodka [1.7K]

Answer:

Option a.  int max = aList.get(0); for (int count = 1; count < aList.size(); count++) { if (aList.get(count) > max) { max = aList.get(count); } }

is the correct code snippet.

Explanation:

Following is given the explanation for the code snippet to find largest value in an integer array list aList.

  1. From the array list aList, very first element having index 0 will be stored in the variable max (having data type int).
  2. By using for starting from count =1 to count = size of array (aList), we will compare each element of the array with first element of the array.
  3. If any of the checked element get greater from the first element, it gets replaced in the variable max and the count is increased by 1 so that the next element may be checked.
  4. When the loop will end, the variable max will have the greatest value from the array aList.

i hope it will help you!

7 0
3 years ago
Read 2 more answers
ANSWER QUICKLY PLEASE
DochEvi [55]

Explanation:

I don't know what is the question.

? should have the value of 4

binary digit 10000011 is equal to 128 plus 2 plus 1 = 131 in decimal

3 0
3 years ago
Which of the following are vector graphic file formats? Choose all that apply.
ddd [48]

i need pics to see what it is



5 0
3 years ago
For most people, the most effective way to save is:
oksian1 [2.3K]
I would say it's by creating a spending budget. 
3 0
3 years ago
Which file types have .exe and .png as their extensions?
uysha [10]
.png are for photos and .exe are for programs.
6 0
3 years ago
Read 2 more answers
Other questions:
  • What is the purpose of a search engine?
    10·2 answers
  • Fill in the function shopSmart(orders,shops) in shopSmart.py, which takes an orderList (like the kind passed in to FruitShop.get
    6·1 answer
  • Predictive coding software leverages .............................when experts review a subset of documents to teach the softwar
    15·1 answer
  • What are the long-term consequences for John’s health and wellness if he continues to use this technique
    15·1 answer
  • Refer to the exhibit. One end of the cable is terminated as displayed, and the other end is terminated in accordance with the T5
    7·1 answer
  • InJava garbage collection is done by_______________JVM (Java VirtualMachine)ProgrammerBoth JVM (Java Virtual Machine)and Program
    9·1 answer
  • What are 3 important reasons to reconcile bank and credit card accounts at set dates?
    15·1 answer
  • Which of these communication avenues is not regulated by the Federal Communications Commission (FCC)?
    12·1 answer
  • What is one example of an emerging class of software
    12·1 answer
  • I'm doing a VHDL program in Vivado, using a zyboz7 20, which would have 2 teams, each of them with different buttons and led lig
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!