Write a program that prints the range of a sequence of


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.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write a program that prints the range of a sequence of
Reference No:- TGS02691464

Expected delivery within 24 Hours