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
Concept explainers
Textbook Question
Chapter 1, Problem 16E
Revise the main routine of the longest-line
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Create a technique for reducing two counts from 10,000 to 1 and then displaying their
values on the computer screen. To minimize the number of counters, your program
will employ a function.
A program is needed to monitor the user’s input and make sure that the text that was entered has balanced paranthesis. There are two types of paranthesis possible in the text: (a) The usual type which uses the symbols ( and ) (b) The square type which uses the symbols [ and ] Note that the text can also have spaces and the alpabet letters from a to z. Apply what you learned in this course (and especially in Chapters 5 and 7) to design a Nondeterministic Push-Down Automaton (NPDA) that can be used to parse the text and make sure that the paranthesis included in it are balanced and that every open paranthesis must be closed with the close paranthesis symbol. For example, the following text does not contain syntax errors and the NPDA should accept it and stop in a final state: The cat (which was running) jumped in to the (normal (although large)) hat. We should buy (in the case that [all are here] two large (bottles) of Coke). However the following text has a syntax error because the…
Your job is to find the length of the longest word in a text with no punctuation or special characters of any kind - only contains words. To do so, please write a C-program that takes as a input first the number of words in a text, followed by all of the words in the text. The output of your program should be the length of the longest word in the text.
To simplify your program, you can assume that the longest word will not exceed 100 characters.
Examples
Input:
14This is a simple example textwe have to find the largest word length
Output:
7
Input:
7All cats are grey in the dark
Output:
4
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
Book Club Points Serendipity Booksellers has a book club that awards points to its customers based on the numbe...
Starting Out with Python (3rd Edition)
(True or False) If is the length of str, then is the string consisting of the last character of str.
Introduction to Programming Using Visual Basic (10th Edition)
Practice Problem 11.3 (solution page 967) Write a program dd2hex.c that converts its dotted-decimal argument to...
Computer Systems: A Programmer's Perspective (3rd Edition)
What output will be produced by the following code, when embedded in a complete program? int x = 200; cout Sta...
Problem Solving with C++ (10th Edition)
_____ are characters or symbols that perform operations on one or more operands.
Starting Out With Visual Basic (7th Edition)
Create a new class called Dog that is derived from the Pet class given in Listing 6.1 of Chapter 6. The new cla...
Java: An Introduction to Problem Solving and Programming (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
- 2. In Python programming language, write a program to input a string and then add the string "programming" to that string and print the result in the output. If the input string is equal to "programming" then print the original string in the output.arrow_forwardModify the previous program. Make it so the sum of the number is displayed.arrow_forwardCreate C program that loops from 1 to 30 and prints out each value on a separate line, except print out "Fizz" for every multiple of 3, "Buzz" for every multiple of 5, and "FizzBuzz" for every multiple oof 3 and 5.arrow_forward
- You are conducting a linguistic study and are interested in finding words that contain the letter 't' or 'T' in the first half of the word (including the middle letter if there is one). Specifically, if the first half of the word does contain a 't' or a 'T', your program should output a 1. If the first half does not contain the letter 't' or 'T', but the second half does, then your program should output a 2. Otherwise, if there is no 't' or 'T' in the word at all, your program's output should be -1. You may assume that the word entered does not have more than 50 letters.arrow_forwardTake user input for a sentence (character by character) and count total number of vowels bothindividually and collectively. Your program should output• Total Number of Vowels• Total Number of a’s• Total Number of e’s• Total Number of i’s• Total Number of o’s• Total Number of u’sRemember that the vowels can be upper or lower case both.arrow_forwardA new species of rabbit is found at AGU Sumer Campus. Scientists decide to analyze the movement of that creature. After applying several lab tests, they understand its algorithm. That rabbit is moving t cm away when it jumps. Then, suddenly, it returns back k cm to jump again. You should help the scientists to calculate how many jumps are needed to go m cm apart from the initial position. Input Format Your program will take 3 integer values, t, k, and m, respectively. Constraints - Output Format One line output will be showing the number of jumps. Sample Input 0 4 1 5 Sample Output 0 2arrow_forward
- A new species of rabbit is found at AGU Sumer Campus. Scientists decide to analyze the movement of that creature. After applying several lab tests, they understand its algorithm. That rabbit is moving t cm away when it jumps. Then, suddenly, it returns back k cm to jump again. You should help the scientists to calculate how many jumps are needed to go m cm apart from the initial position. Input Format Your program will take 3 integer values, t, k, and m, respectively. Constraints - Output Format One line output will be showing the number of jumps. !! please solve in a different ways!!arrow_forwardThe geometric mean of a set of positive numbers x through x, is defined as the nth root of the product of the numbers: (eq) geometric mean = Vxx,xz. Write a MATLAB program that will accept arbitrary number of positive input values and calculate the arithmetic mean (i.e., the avarage) and the geometric mean of the numbers. Use a while loop to get the input values, and terminate the inputs when a user enters a negative number. Test your program by calculating the average and geometric mean of the four numbers 10, 5, 2, and 5. Script e A Save C Reset I MATLAB Documentation 1 % Define variables: -- Input values -- Geometric mean 2 % x % g 4 % nvals -- Number of input values 5 % prod 6 % Initialize product and nvals 7 i = 1; -- Product of input values 8 10 % Simulate User Input 11 % Read the first number 12 sampleData = [10 5 2 5 -1]; 13 x = sampleData(1,1); 14 disp(strcat('Enter first number: ',int2str(x))); 15 % Read the remaining numbers 16 17 18 % Simulate User Input starting 2nd…arrow_forwardRead in 5 numbers from the keyboard and, if any of the entered numbers is < 0, then print out “Negative” else print out “All nonnegative”. Your assignment is to develop pseudocode to accomplish this task.arrow_forward
- Show the Mnemonics of the following program.arrow_forwardConsidering string manipulations, create a Python program that asks for two string input, S1 and S2, and displays the two strings in alphabetical order. Assume that the two strings are not empty.arrow_forwardWrite a program to read and print 6 temperatures for 6 days and find the average for these degrees and determine the largest degree and then print the main diameter from it and the upper triangle of the secondary diameterarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Computational Software for Intelligent System Design; Author: Cadence Design Systems;https://www.youtube.com/watch?v=dLXZ6bM--j0;License: Standard Youtube License