Write a program that prints range of a sequence of integers

Assignment Help Computer Engineering
Reference no: EM131895973

Assignment

1. Write a program that takes two arguments, two positive integers m and n such that m < n, and prints the sum m + ( m + 1) + • • • + n.

2. Write a program that prints the range of a sequence of integers provided through stdin. For example, the range of -3, 15, -8, 29, 17 is 29 - (-8) = 37.

3. Write a program according to the following specification:

a. It has two possible command-line arguments: -s indicates "shout" mode, while -w indicates "whisper" mode.
b. It reads an arbitrary list of strings from stdin.
c. It writes the strings to stdout, except that it writes all letters in either uppercase or lowercase according to the mode.

4. Write a program according to the following specification:

a. It reads an arbitrary list of strings from stdin.
b. It records the number of vowels encountered.
c. It prints the number of occurrences of each vowel to stdout.

5. Write a program, called hide, according to the following specification:

a. It has two possible arguments: -encrypt indicates encryption mode, while -decrypt indicates decryption mode.

b. It reads an arbitrary list of strings from stdin.

c. It applies a cypher to the strings. You may invent your own, but a simple one is to shift the letters by a constant amount (for example, 'a' becomes 'd', and 'z' becomes 'c'). It either encrypts or decrypts the strings ("shifts" or "deshifts" the letters) depending on the mode.

d. It prints the encrypted or decrypted text to stdout.

e. At minimum, it should be able to handle text consisting only of lowercase letters. For example, if the message attention home planet stop prepare invasion stop earth is ripe for the taking stop cu soon full stop is in file msg.txt, then $ ./hide -encrypt < msg.txt > msge.txt would produce the following cyphertext in file msge.txt if hide is using a shift of 12: mffqzfuaztayqbxmzqfefabbdqbmdquzhmeuazefabqmdftuedubq rad ftqfmwuzsefabogeaazrgxxefab.

f. Then $ ./hide -decrypt < msge.txt would yield the original message. Using Unix piping would also result in the output of the original message: $ ./hide -encrypt < msg.txt | ./hide -decrypt To achieve the proper shift, use the following formula: 'a' + (((c - 'a') + sh) % 26) The idea is to find c's position in the alphabet (c - 'a'), add the shift ((c - 'a') + sh) modulo 26 (((c - 'a') + sh) % 26), and finally translate the character back into the ASCII range for lowercase letters. To unshift, set sh to 26 - sh and use the same formula. For example, if sh is 12, then 'a' + (((c - 'a') + 12) % 26) yields 'q' if c == 'e' since 'q' is 12 characters later than 'e'; and 'f' if c == 't' since 'f' is 12 characters later than 't' modulo 26.

Reference no: EM131895973

Questions Cloud

What is the relative distance of each to the united states : Apply the CAGE distance framework to the six foreign countries where Clif Bar is operating. What is the relative distance of each to the United States?
Percentage of cytosine in the dna of organism : What is the percentage of cytosine in the DNA of this organism?
Chromosomes shorten after each round of replication : You identify a mutant whose chromosomes shorten after each round of replication. A mutation in which gene would explain this observation?
Propose a model of alternative splicing : Propose a model of alternative splicing for this gene that can account for these facts.
Write a program that prints range of a sequence of integers : Write a program that prints the range of a sequence of integers provided through stdin. For example, the range of -3, 15, -8, 29, 17 is 29 - (-8) = 37.
Pericentric inversion takes place on the x chromosome : If a pericentric inversion takes place on the X chromosome, will it affect males, females, or both? Why?
Prepare a trial balance for the end of the period : Record the following transactions in the journal of Howell Consulting. Explanations are not required. Prepare a trial balance for the end of the period
Combination of the mutants and looks : To determine whether these mutations occur at the same functional gene, he simultaneously infects E. coli K with paired combination of the mutants and looks
How would you describe the software process you used : How would you describe the software process you used to accomplish question 3? Which of the primary software activities did you perform, and in what order?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Find an instance method whenever the method is called

A ____ reference is an automatically created variable that holds the address of an object and passes it to an instance method whenever the method is known.

  Sizes of the original-zebras and zebras files

Go to www.cs.vu.nl/ ast and click on covered writing link. Follow the instructions to extract the plays. Answer the following questions: (a) What are the sizes of the original-zebras and zebras files?

  Explain the concept of programmability

how this benefits the purchaser of a console gaming system, such as the XBox.

  What are similarities and differences between osha and niosh

Discuss the responsibility and authority of OSHA as well as OSHA standards. What are the similarities and differences between OSHA and NIOSH?

  What is difference between bitmapped fonts and outline fonts

What is the difference between Bitmapped fonts and Outline fonts or Speech recognition and Speech synthesis. Explain what is an authoring software? And give some examples of the authoring software that you may use?

  Why would one refer to the r class in a java file

Why would one refer to the R class in a Java file? What is the class of the object returned by the get Text method of an Edit Text object?

  What transform a network to a secure network

How do I transform a network to the secure network? What tools should I have and what kind of hardware do I need to have a basic secure network.

  Nbspthe last stop boutique is having a five-day sale each

nbspthe last stop boutique is having a five-day sale. each day startingnbspon monday the price will drop 10 of the

  You are the information security officer at a medium-sized

you are the information security officer at a medium-sized company. the cio asks you to explain why you believe it is

  Compare and contrast the given two companies

In a 3-4 page paper, APA Format, compare and contrast these two companies and how they use process analytics.

  Write the css code for an external style sheet

Write the CSS code for an external style sheet that configures the text to be brown, 1.2em in size, and in Arial, Verdana, or a sans-serif font.

  Show that the unit must change with distance

We have proven that radiance does not go down along a straight line in a non-absorbing medium, which makes it a useful unit.

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