C How to Program (8th Edition)
8th Edition
ISBN: 9780133976892
Author: Paul J. Deitel, Harvey Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 8, Problem 8.10E
Program Plan Intro
Program Plan:
- Declare character type variable string1 and string2 to read two strings from the user.
- Declare variable n of type int to store the number of characters to be compared.
- Use function strcmp to compare the two string.
- Declare integer type variable result to store the result of the comparison of two string.
- Display the comparison result using printf() function.
Program Description:
The program reads two strings and compares their n characters using strcmp function. Then determines if the first string is less than, equal to or greater than the second string.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
(C++ language)
please quickly thanks !!
use Python
(Count the letters in a string) Write a function that counts the number of letters in a string using the following header: def countLetters(s) : Write a test program that prompts the user to enter a string and displays the number of letters in the string.
the answer should be in python.
Chapter 8 Solutions
C How to Program (8th Edition)
Ch. 8 - (Character Testing) Write a program that inputs a...Ch. 8 - Prob. 8.6ECh. 8 - (Convening Strings to Integers for Calculations)...Ch. 8 - (Converting Strings to Floating Point for...Ch. 8 - Prob. 8.9ECh. 8 - Prob. 8.10ECh. 8 - (Random Sentences) Write a program that uses...Ch. 8 - (Pig Latin) Write a program that encodes...Ch. 8 - (Tokenizing Telephone Numbers) Write a program...Ch. 8 - (Displaying a Sentence with Its Words Reversed)...
Ch. 8 - (Searching for Substrings) Write a program that...Ch. 8 - (Counting the Occurrences of a Substring) Write a...Ch. 8 - (Counting the Occurrences of a Character) Write a...Ch. 8 - Prob. 8.19ECh. 8 - (Counting the Number of Words in a String) Write a...Ch. 8 - (Alphabetizing a List of Strings) Use the...Ch. 8 - Prob. 8.22ECh. 8 - (Strings Starting with b) Write a program that...Ch. 8 - (Strings Ending with ed) Write a program that...Ch. 8 - (Printing Letters for Various ASCII Codes) Write a...Ch. 8 - (Write Your Own Character-Handling Functions)...Ch. 8 - Prob. 8.27ECh. 8 - Prob. 8.28ECh. 8 - Prob. 8.29ECh. 8 - Prob. 8.30ECh. 8 - (Text Analysis) The availability of computers with...Ch. 8 - (Printing Dates in Various Formats) Dates are...Ch. 8 - (Check Protection) Computers are frequently used...Ch. 8 - (Writing the Word Equivalent of a Check Amount)...Ch. 8 - Prob. 8.35ASME
Knowledge Booster
Similar questions
- integer) Write a function that computes the sum of the digits in an integer. Use the following function header:def sumDigits(n):For example, sumDigits(234) returns 9 (Hint: Use the % operator to extract digits, and the // operator to remove the extracted digit. For instance, toextract 4 from 234, use 234 % 10 To remove 4 from 234, use 234 // 10 (=23) Use a loop to repeatedly extract and remove the digits until all the digits are extracted.) Write a test program that prompts the user to enter an integer and displays the sum of all its digits.arrow_forwardQ2) (Perfect Numbers) An integer number is said to be a perfect number if its factors, including 1 (but not the number itself), sum to the number. For example, 6 is a perfect number because 6 = 1 + 2 + 3. Write a function perfect that determines if parameter number is a perfect number. Use this function in a program that determines and prints all the perfect numbers between 1 and 1000. Print the factors of each perfect number to confirm that the number is indeed perfect. Challenge the power of your computer by testing numbers much larger than 1000.arrow_forward(Python matplotlib or seaborn) CPU Usage We have the hourly average CPU usage for a worker's computer over the course of a week. Each row of data represents a day of the week starting with Monday. Each column of data is an hour in the day starting with 0 being midnight. Create a chart that shows the CPU usage over the week. You should be able to answer the following questions using the chart: When does the worker typically take lunch? Did the worker do work on the weekend? On which weekday did the worker start working on their computer at the latest hour? cpu_usage = [ [2, 2, 4, 2, 4, 1, 1, 4, 4, 12, 22, 23, 45, 9, 33, 56, 23, 40, 21, 6, 6, 2, 2, 3], # Monday [1, 2, 3, 2, 3, 2, 3, 2, 7, 22, 45, 44, 33, 9, 23, 19, 33, 56, 12, 2, 3, 1, 2, 2], # Tuesday [2, 3, 1, 2, 4, 4, 2, 2, 1, 2, 5, 31, 54, 7, 6, 34, 68, 34, 49, 6, 6, 2, 2, 3], # Wednesday [1, 2, 3, 2, 4, 1, 2, 4, 1, 17, 24, 18, 41, 3, 44, 42, 12, 36, 41, 2, 2, 4, 2, 4], # Thursday [4, 1, 2, 2, 3, 2, 5, 1, 2, 12, 33, 27, 43, 8,…arrow_forward
- rin t] (Replace strings) Write the following function that replaces the occurrence of a substring old substring new_substring in the string s. The function returns true if string s is changed, and otherwise, it returns false. bool replace_strings(string& s, with new substring a const string& old_string, const string& new_string) Write a test program that prompts the user to enter three strings, i.e., s, old_string, and new_string, and display the replaced string.arrow_forwardComputer Sciencearrow_forwardProgramming Language : R programming (R Studio) A twin prime is a prime that has a prime gap of two. Sometimes the term twin prime isused for a pair of twin primes. For example, the five twin prime pairs are (3, 5), (5, 7),(11, 13), (17, 19) and (29, 31). Write a function that returns the number of all twin primepairs between 1 and a given number n.arrow_forward
- 4. Odd-Even-inator by CodeChum Admin My friends are geeking out with this new device I invented. It checks if a number is even or odd! ? Do you want to try it out? Instructions: In the code editor, you are provided with a function that checks whether a number is even or odd. Your task is to ask the user for the number of integer, n, they want to input and then the actual n number values. For each of the number, check whether it is even or odd using the function provided for you. Make sure to print the correct, required message. Input 1. Integer n 2. N integer valuesarrow_forward5. (Algebra: solve 2 X 2 linear equations) You can use Cramer's rule to solve the following 2 X 2 system of linear equation: ax + by = e cx + dy = f ● x = ed - bf bc ad y = af - ec ad bc - Write a program that prompts the user to enter a, b, c, d, e, and f and display the result. If ad- bc is 0, report that The equation has no solution. Enter a, b, c, d, e, f: 9.0, 4.0, 3.0, -5.0, -6.0, -21.0 Enter x is -2.0 and y is 3.0 Enter a, b, c, d, e, f: 1.0, 2.0, 2.0, 4.0, 4.0, 5.0 Enter The equation has no solutionarrow_forwardUsing “Def” keyword write a function that compares two arrays, if both are the same it will return true, else it will return false. (The function name will be AreArraysEqual) Not: Write some print functions to see the outputs inside each function. (Python programming language)arrow_forward
- (Financial: credit card number validation) Credit card numbers follow certain pat- terns. A credit card number must have between 13 and 16 digits. It must start with: 4 for Visa cards 5 for Master cards 37 for American Express cards 6 for Discover cards In 1954, Hans Luhn of IBM proposed an algorithm for validating credit card numbers. The algorithm is useful to determine whether a card number is entered correctly or whether a credit card is scanned correctly by a scanner. Credit card numbers are generated following this validity check, commonly known as the Luhn check or the Mod 10 check, which can be described as follows (for illustra- tion, consider the card number 4388576018402626): 1. Double every second digit from right to left. If doubling of a digit results in a two-digit number, add up the two digits to get a single-digit number. 4388576018402626 → 2 * 2 = 4 → 2 * 2 = 4 → 4 * 2 = 8 → 1 * 2 = 2 6 * 2 = 12 (1+ 2 = 3) → 5 * 2 = 10 (1+ 0 = 1) → 8 * 2 = 16 (1 + 6 = 7) → 4 * 2 = 8arrow_forwardplease quickly thanks ! use Pythonarrow_forwardUse python fast 20 minutesarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning