Write a program that prints all numbers from 1 to n

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

Programming C++

Exercise

Exercise 1. Use the for statement in a program that prints all the numbers from n1 to n2, where n1 and n2 are two numbers specified by the user.

(Hint: You'll need to prompt for the two values; then, inside the for statement, initialize i to n1, and use n2 in the loop condition.)

Exercise 2. Rewrite the example so that it prints all the numbers from n to 1 in reverse order. For example, the user enters 5, and the program prints 5 4 3 2 1.

(Hint: In the for loop, initialize i to n, use the condition i >= 1, and subtract 1 from i in the increment step.)

Exercise 3. Write a program that prints all numbers from 1 to n, but prints only even numbers or only odd numbers. Each number printed will be 2 higher than the last.

Reference no: EM132107912

Questions Cloud

What is the growth outlook : What is the Growth outlook and the Level of barriers to entry the Petroleum Industry?
Explain why german market is the better one : Management group believe German is better than England. List those two countries' advantage and disadvantage and explain why German market is the better one
Compute a factorial that can fit within an unsigned 16 bit : You will use your newfound looping knowledge to compute a factorial that can fit within an unsigned 16 bit integer.
What is the fair price of one afa bond to the nearest cent : Given the risk of AFA and its recent credit downgrade to CC, the required return on these bonds is now 17.5%.
Write a program that prints all numbers from 1 to n : Use the for statement in a program that prints all the numbers from n1 to n2, where n1 and n2 are two numbers specified by the user.
What is the current value of bank bills : If the current 180-day bill rate is 6.9% p.a., what is the current value of these bank bills to the nearest dollar?
Write a simulator in which one round of simulation involves : Write a simulator in which one round of simulation involves flipping a set of ten unfair coins in which there is a fixed likelihood.
Report the number of guesses made and terminate execution : Imagine that the user will write down a positive integer x on a piece of paper and your program will repeatedly ask questions in order to guess what x is.
Implement a recursive quicksort algorithm : For this lab, you will first populate an array with integer values provided by a user and then you will sort the array.

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