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

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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