C Programming Language
2nd Edition
ISBN: 9780131103627
Author: Brian W. Kernighan, Dennis M. Ritchie, Dennis Ritchie
Publisher: Prentice Hall
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 1, Problem 22E
Write a
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Write a program to display information about user inputs.
Each column occupies 15 spaces. Given the date of birth is November 24th, 1992,Abbreviated format: each column is in the left alignment, and the dob is displayed as 24/Nov/1992.Normal format: each column is in the center alignment, and the dob is displayed as 24-11-1992 .Format other than entering "A" and "N": the first two columns are in the center alignment, the last column is in the left alignment, and the dob is displayed as 1992-11-24.The program must use if-else statements and string format.The program must work exactly like the following examples.
For example:
Input
Result
John Smith 24-11-1992 A
Enter your first name: John Enter your last name: Smith Enter your dob (DD-MM-YYYY): 24-11-1992 Choose a format: (A)bbreviated (N)ormal: A First Name Last Name Date of Birth John Smith 24/Nov/1992
John Smith 24-11-1992 N
Enter your first name: John Enter your last name: Smith Enter your dob (DD-MM-YYYY): 24-11-1992…
Write a program to ``fold'' long input lines into two or more shorter lines after the last non-blank character that occurs before the n-th column of input. Make sure your program does something intelligent with very long lines, and if there are no blanks or tabs before the specified column.
A.
The original Caesar cypher shifts each character by one: a becomes b, z becomes a, and so on. Let's make it a bit harder, and allow the shifted value to come from the range 1..25 inclusive.
Moreover, let the code preserve the letters' case (lower-case letters will remain lower-case) and all non-alphabetical characters should remain untouched.
Your task is to write a program which:
asks the user for one line of text to encrypt;
asks the user for a shift value (an integer number from the range 1..25 - note: you should force the user to enter a valid shift value (don't give up and don't let bad data fool you!)
Test your code using the data we've provided.
Test data
Sample input:
abcxyzABCxyz 123
2
Sample output:
cdezabCDEzab 123
Sample input:
The die is cast
25
Sample output:
Sgd chd hr bzrs
Chapter 1 Solutions
C Programming Language
Ch. 1 - Run the hello, world program on your system....Ch. 1 - Prob. 2ECh. 1 - Modify the temperature conversion program to print...Ch. 1 - Write a program to print the corresponding Celsius...Ch. 1 - Prob. 5ECh. 1 - Prob. 6ECh. 1 - Write a program to print the value of EOF.Ch. 1 - Write a program to count blanks, tabs and...Ch. 1 - Write a program to copy its input to its output,...Ch. 1 - Write a program to copy its input to its output,...
Ch. 1 - Prob. 11ECh. 1 - Write a program that prints its input one word per...Ch. 1 - Write a program to print a histogram of the...Ch. 1 - Write a program to print a histogram of the...Ch. 1 - Rewrite the temperature conversion program of...Ch. 1 - Revise the main routine of the longest-line...Ch. 1 - Write a program to print all input lines that are...Ch. 1 - Write a program to remove trailing blanks and tabs...Ch. 1 - Write a function reverse(s) that reverses the...Ch. 1 - Write a program detab that replaces tabs in the...Ch. 1 - Write a program entab that replaces strings of...Ch. 1 - Write a program to fold long input lines into two...Ch. 1 - Prob. 23ECh. 1 - Write a program to check a C program for...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Kilometer Converter The Kilometer Converter Problem Write a program that asks the user to enter a distance in K...
Starting Out with Python (3rd Edition)
In the following exercises, write a program to carry out the task. The program should use variables for each of...
Introduction To Programming Using Visual Basic (11th Edition)
What is the difference between private members and protected members?
Starting Out with Java: Early Objects (6th Edition)
Write a pseudocode statement that declares the variable total so it can hold integers. Initialize the variable ...
Starting Out with Programming Logic and Design (4th Edition)
Identify the syntactic errors in the following program. Then type in and run the corrected program to ensure yo...
Programming in C
Write a function named timesTen that accepts an argument. When the function is called, it should display the pr...
Starting Out with C++ from Control Structures to Objects (8th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- You will select one of the problems below and create a program that uses nested selections to solve the problem.Do not use Boolean operators. Write a program that reads three edges for a triangle and computes the perimeter if the input is valid. Otherwise, display that the input is invalid. The input is valid if the sum of every pair of two edges is greater than the remaining edge.arrow_forwardWrite a program that prompts the user to input a string and outputs the string in uppercase letters. (Use a character array to store the string.)arrow_forwardWrite a program entab that replaces strings of blanks by the minimum number of tabs and blanks to achieve the same spacing. Use the same tab stops as for detab. When either a tab or a single blank would suffice to reach a tab stop, which should be given preference?arrow_forward
- Write a program that will create a twelve line times table from 8 to 19 based on user input. The table will have three columns centred correctly on the screen with proper column titles. All programs will have a title, introduction, correctly ask for user input and display the resultant design. Do not use any built-in math functions.arrow_forwardProgram a simplified Galton board in python. It is required that: The user must select the number of rows n of the board The distribution resulting from dropping the beads should be displayed on the screen. Display an animation where the number of rows n increases over time.All resulting distributions must be scaled to the interval [0, 1], so that it is possible toappreciate the convergence to the normal distribution. Consider n from 1 to 80.arrow_forwardWrite a program detab that replaces tabs in the input with the proper number of blanks to space to the next tab stop. Assume a fixed set of tab stops, say every n columns. Should n be a variable or a symbolic parameter?arrow_forward
- Write a program to create the following figure by using nested for loops. Please assign the number of lines as a class constant variable in order to change the size of the figure as in the sample figure.arrow_forwardMy problem is the column in the photo (column [7]) includes a "$". So it would be read as a string. The other picture is my line of code that needs to be changed to accumulate the "$". My question is can someone rewrite this line/ write another line of code that could work with this column so my code can run?arrow_forwardWrite a program in BGI to draw a line using DDA algorithm when (? > 1) starting from (50, 100) to (250, 450). Use Yellow color for all pixel points with a window size of (600, 600) titled “DDA Algorithm”. (Note: the program should display error massages when the slope is equal or less than 1)arrow_forward
- ISP- Java Write a program that will output a right triangle based on user specified input height (int) and specified input symbol (char). The first line will have one user-specified character, such as % or *. Each subsequent line will have one additional user-specified character until the number in the triangle's base reaches specified input height. Output a space after each user-specified character, including after the line's last user-specified character. Hint: Use a nested for loop. Ex: If the input is: Enter a character: * Enter triangle height: 8 the output is: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *arrow_forwardWrite a program that plots the sine function in red and the cosecant function in blue. Hints: The above scene is 800 pixels wide and 600 pixels tall. On the x-axis, -2π is at pixel (200, 300),the center of the axis is at (400, 300), and 2π is at (600, 300). Draw your text for these points near (butnot directly on) these coordinates. The Unicode for π is \u03c0. To display -2π, use Text(x, y, “-2\u03c0”). My program used Font.font("Georgia", 25) as the font for each of the Text objects. (Recallthat you use the setFont(…) on a Text object to set its font. For a trigonometric function like Math.sin(x), x is in radians. You can use the following loop to add the points to a polyline for the sine curve: Polyline sineCurve = new Polyline(); ObservableList list = sineCurve.getPoints(); for (double x = -340; x <= 340; x++) {list.add(x + 400);list.add(300 – 100 * Math.sin((x / 200.0) * 2 * Math.PI)); Your program can draw the entire sine curve as a single polyline. Remember to set its color…arrow_forwardWrite a Python program that prints the (x, y) coordinates for an M by N image (with M=10 and N=5). Write Python program that will ask the user to enter a lower and upper range values and a divisor. Then the program must print all the integer numbers in that interval (including both bounds) that are divisible by the divisor. Write Python program that will ask the user to enter positive numbers, to end the program the user will enter a negative number. When this occurs, print the average of the positive numbers rounded to 2 decimal places. Write a Python program that uses a for-loop to print all integers between 300 and 600 (inclusive) that are divisible by both 3 and 5.Print how many of these numbers were found.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY