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
In asps, the code to tie the database to the web site is typically written in javascript or ____.
Dominik [7]
In asps, the code to tie the database to the web site is typically written in javascript or VBScript<span>(Visual Basic Script).
</span>VBScript is an interpreted script language from Microsoft<span> with syntax very similar to that of Visual Basic.
</span><span>Most often VBScript is used for Quick Test Professional (QTP), which is a test automation tool.</span>
4 0
3 years ago
____ that allow individuals to perform specific tasks are launched via the operating system, such as by using the windows start
schepotkina [342]
Programs that allow individuals to perform specific tasks are launched via the operating system, such as by using the windows start menu on windows computers. Programm is a set of instructions written for a computer.<span>The Start menu contains icons for all installed programs and data collections, usually for programs.</span>
3 0
3 years ago
Or operator of boolean algebra is denoted by:<br>*<br>+<br>-<br>.​
OlgaM077 [116]

Answer:

or operator is denoted by + sign

7 0
3 years ago
Margaret Sullivan is a TLD expert and a domain name consultant. Which of the following domains is she likely to suggest to her c
zmey [24]

Answer:

B- .net

Explanation:

.NET is a domain which can be used to create different applications which include web, mobile, desktop, gaming, cloud among others and it often consists of different programming language that helps in creating different applications thereby providing the base services needed to interact with the operating system.

Therefore Margaret Sullivan who is a TLD expert and a domain name consultant should suggest .NET domain to her clients who want to start Internet companies.

4 0
4 years ago
What does OSS mean? ??
Viefleur [7K]
Ooeration support system. OSS is IT for running a communications network.
6 0
3 years ago
Other questions:
  • Paulene is using this table in Word,and she started with the cursor in the box that read “Flavor”. she then hits Alt+End,The the
    7·1 answer
  • HELP QUICK!!!
    14·2 answers
  • How much speedup would result from running application A on the entire 22-core processor, as compared to running it serially?
    10·1 answer
  • How does a hard drive work?
    5·1 answer
  • Why are user manuals important? Select all that apply.
    6·1 answer
  • Wiliam would like to sort a list of items after the data is already entered
    7·2 answers
  • can anyone sub to my youttube channel pls, its called Yakobu, and Im trying to reach 100 subs by the end of the month :)
    9·1 answer
  • What internal commands can we use when in interactive mode? can we use CLS and CD?
    6·1 answer
  • Scrabble is a word game in which words are constructed from letter tiles, each letter tile containing a point value. The value o
    8·1 answer
  • ANSWER ASAP! 50 POINTS!!!!
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!