Write a for loop that counts only the odd numbers

Assignment Help C/C++ Programming
Reference no: EM131207294

Here are two examples:

if(counter==7)

continue;

if(counter==7)

break;

1. Write a for loop that counts only the odd numbers out of the first five numbers entered from the keyboard, but does not count (skips) the number 7. Use the keyword continue to skip 7 inside the loop

2. Write the same program above, but exit the for loop using break if the number 7 is entered.

#include <iostream>

using namespace std;

intmain() {

                int sum = 0;

                intnum[5];

                for (int counter = 0; counter < 5; counter++) {

                                cout<< "Enter a Number: ";

                                cin>>num[counter];

                                if (num[counter] % 2 != 0)

           sum = sum + num[counter];

                }

                cout<< "Sum of Odd Numbers is: " << sum <<endl;

                system("pause");

                return 0;

}

Reference no: EM131207294

Questions Cloud

Explain role of us supreme court in criminal justice policy : Examine potential issues that must be evaluated in the future by the U.S. Supreme Court that will further shape criminal justice policy (e.g., you could discuss how advances in technology such as surveillance, computer analysis, drones, police equ..
Advertisement elasticity of demand for good : The price elasticity of good Y is -1.46. The advertisement elasticity of demand for good Y is 3.53. And these two elasticities are assumed to remain constant over the planned price and advertisiment changes.
Undergoes a thermodynamic cycle : A certain fixed mass system involves R-22 and undergoes a thermodynamic cycle. The cycle involves exactly two processes: A and B. Process A starts at state 1 and ends at state 2, and is the initial process of the cycle. The following are also give..
Find type and impedance in ohms of series circuit elements : Find the type and impedance in ohms of the series circuit elements that must be in the closed container of given figure for the indicated voltages and currents to exist at the input terminals.
Write a for loop that counts only the odd numbers : Write a for loop that counts only the odd numbers out of the first five numbers entered from the keyboard, but does not count (skips) the number 7. Use the keyword continue to skip 7 inside the loop
Formula for the endogenous variables : Determine a successful separation into exogenous and endogenous variables, and c) find an explicit formula for the endogenous variables in terms of the exogenous ones:
Explain the accepted identification procedures : Explain the accepted identification procedures, prepare a brief for excluding pre-trial identifications, and brief the Biggers case to demonstrate the factors the Courts will consider as a part of their ruling on whether a proper identification pr..
Consistent with the claim : Solomon company prints baseball cards, The company claims that 40% of the cards are rookies, 70% veterans and 10% are all stars, Suppose a random sample of 100cards has 50 rookies, 48 veterans and 8 all stars. is this consistent with the claim? Us..
How is biologos different from intelligent design : How is BioLogos different from Evolutionism, Intelligent Design, and Creationism? Why should all citizens and scientists embrace religion and all religion embrace science?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd