Question

The code needs to be in C #. You can define the upper and lower bounds....

The code needs to be in C #. You can define the upper and lower bounds.

Q. You are given a lower and an upper bound for a range of integer numbers. Write a program that prints the range of numbers in the reverse order and prints it back on the original order.

Homework Answers

Answer #1
using System;

public class Sequence
{
    public static void Main(string[] args)
    {
        Console.Write("Enter upper bound: ");
        int upper = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter lower bound: ");
        int lower = Convert.ToInt32(Console.ReadLine());
        Console.WriteLine("Reverse order: ");
        for (int i = upper; i >= lower; i--)
        {
            Console.WriteLine(i);
        }
        Console.WriteLine("Original order: ");
        for (int i = lower; i <= upper; i++)
        {
            Console.WriteLine(i);
        }
    }
}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write the code in C# List the evens or the odds. You are given a lower...
Write the code in C# List the evens or the odds. You are given a lower and an upper bound for a range of integer numbers. Then a command specifies if you need to list all even or odd numbers in the given range.
The code needs to be in C #. Write a simple program that reads from the...
The code needs to be in C #. Write a simple program that reads from the console a set of numbers and prints back onto the console the smallest number from the collection
This phyton program requires you to accept from the user a three-digit integer (100-999), and prints...
This phyton program requires you to accept from the user a three-digit integer (100-999), and prints the reverse of that integer. You can assume that the input is an integer, but should not assume it's in the right range. If it's not in the right range, print "Illegal input:" and the number. Here are three sample runs: Enter a three digit decimal integer: 234 The number in reverse is: 432 Enter a three digit decimal integer: 1345 Illegal input: 1345...
Write a program in C# that reverses a collection and removes elements that are divisible by...
Write a program in C# that reverses a collection and removes elements that are divisible by a given integer n. You will give the lower and upper limits for the range of elements and the integer n, like 1, 6, 2. Your output should be 5,3,1
Write a full C++ program to read a series of integer numbers from standard input and...
Write a full C++ program to read a series of integer numbers from standard input and print them out in reverse order, one per line. You may assume that there will be a minimum of 2 numbers to read and a maximum of 200.
My question that needs an answer is this: Can the C++ compilers catch the mistake of...
My question that needs an answer is this: Can the C++ compilers catch the mistake of using an "=" instead of the comparison operator "==". Show code how you can test this using an if statement in C++, write a small program to demonstrate it. If the compiler does not catch the mistake how would one go about ensuring they are using the correct syntax for the comparison operator? Thank you
C CODE PLZ! All instructions are in sections of code #include <stdio.h> /* TODO: Define 3...
C CODE PLZ! All instructions are in sections of code #include <stdio.h> /* TODO: Define 3 functions input, gcd and lcm in such a way that the main function below compiles correctly and has the correct behavior. The input function prompts the user to enter a non-negative integer. If the user enters a negative integer, the function prints a "sorry" statement and prompts the user again. It keeps on prompting until the user enters a non-negative number. The input function...
Please code C# 7. Write a program that can calculate the sum of all numbers between...
Please code C# 7. Write a program that can calculate the sum of all numbers between 1 and 1000 inclusive (including 1 and 1000)
Please write code in C. Thank you! Write a program that reads a list of integers,...
Please write code in C. Thank you! Write a program that reads a list of integers, and outputs the two smallest integers in the list, in ascending order. The input begins with an integer indicating the number of integers that follow. You can assume that the list will have at least 2 integers and less than 20 integers. Ex: If the input is: 5 10 5 3 21 2 the output is: 2 3 To achieve the above, first read...
How to code this in python Write a program that computes and prints the first 1000...
How to code this in python Write a program that computes and prints the first 1000 prime numbers - simply write out each prime number on a new line. In implementing this solution I want you to define 2 functions: is_prime which can be used to test whether a number is a prime (e.g. is_prime(17) returns True but is_prime(9) returns False) and compute_primes which will return an array (or Python list) of the first n primes where n is passed...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT