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
Ede4ka [16]
3 years ago
7

Write a program that uses a forstatement to calculate and prints the sum of oddnumbers from 1 to 15

Computers and Technology
1 answer:
Tju [1.3M]3 years ago
5 0

Answer:

#include<iostream>

using namespace std;

//main function

int main(){

   //initialization

   int sum_1=0;

   //for loop which run from 1 to 15

   for(int a1=1;a1<=15;a1++){

       if(a1%2==1){

           sum_1 = sum_1 + a1; //take the sum

       }

   }

   //display the result

   cout<<"The sum of odd number is:"<<sum_1<<endl;

   return 0;

}

Explanation:

Include the library iostream for using the input/output instruction.

Create the main function and declare the variable.

Them, take the for loop which runs from 1 to 15 and we also take the if-else conditional statement which checks the condition and if the condition is true, the statement inside the 'if' statement executes.

The condition of odd:

when the odd numbers are divided by 2, they give the remainder 1.

so, in the programming, the operator modules (%) is the only one which gives the output remainder.

suppose, 5%2 it gives the output 1.

so, the condition of an odd number is (number%2==1) we put this condition in the if statement and when the condition is true then, we take the sum of that number and store back in the sum as well.

when all number will check then the loop will terminate and finally, we display the result on the screen.

You might be interested in
What is the technique used to divide information sets into mutually exclusive groups such that the members of each group are as
mars1129 [50]

Answer:

C. Cluster analysis

Explanation:

<em>Cluster analysis </em>or clustering is the task of grouping a set of objects in such a way that objects in the same group are more similar to each other than to those in other groups.

This statistical method is used to group similar objects into respective categories by <em>identifying trends and patterns</em>.

Cluster analysis is typically used in the <em>exploratory phase of research </em>when the researcher does not have any per-conceived hypotheses. It is commonly not the only statistical method used, but rather is done in the early stages of a project to help guide the rest of the analysis.

5 0
4 years ago
Application software developed by the user or at the user’s request is called ____ software.
Zolol [24]
End-User Software. Because it is not professional

4 0
3 years ago
You want to choose software that will be updated on a regular basis. Which of these is most likely to meet your needs?
BARSIC [14]
Operating systems that are up to date like Microsoft windows
8 0
3 years ago
PLEASE HELP ASAP! WILL MARK BRAINLIEST IF THE ANSWER IS CORRECT! I NEED HELP WITH THE 3RD ONE!
Bogdan [553]

Answer:

Explanation:

.1 Display all information from the customer table for all customers that have a balance that is greater than the average balance.

2. Display all information from the rep table for all representatives that have a rate which is equal to the minimum rate for representatives.

3. Display each unique description and price (no duplicates) for all parts that have a quoted price that is greater than the average quoted price for all parts ordered.

4. List all streets where either a customer or a representative is located

5 0
4 years ago
The success of the digital revolution is mostly due to the use of ___?
Lynna [10]

Answer:

The success of digital revolution is mostly due to the use of online advertising.

Explanation:

8 0
3 years ago
Other questions:
  • When searching for an image on your computer, you should look for a file with which of the following extensions?
    6·1 answer
  • A wireless mesh network with 17 computers would need _______________ connections.
    13·1 answer
  • Rite a c++ function, smallestindex, that takes as parameters an int array and its size and returns the index of the first occurr
    15·1 answer
  • You are the project manger for Xylophone Phonics. It produces children's software programs that teach basic reading and math ski
    11·1 answer
  • Which two hardware features would a technician monitor within the bios if a computer was suspected of overheating?
    7·1 answer
  • Union Carbide accident safety policies and procedures were not followed was due to
    14·1 answer
  • Project: big research project
    15·2 answers
  • Need the answer ASAP!!!
    14·1 answer
  • Does anyone want to play nitro type with me for my typing class I put 100 points into this so If you put link or random stuff I
    7·1 answer
  • What is the relationship between the speed of an object in the amount of energy it has? explain
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!