C++   How to Program (Early Objects Version)
C++ How to Program (Early Objects Version)
10th Edition
ISBN: 9780134448824
Author: Paul Deitel; Harvey M. Deitel
Publisher: Pearson Education (US)
Question
Book Icon
Chapter 22, Problem 22.31E
Program Plan Intro

Program Plan:

  • Include header files.
  • Start “main()” function.
  • Accept two strings “s1” and “s2” to compare.
  • Use “strlen()” to compare length of string “s1” with length of “s2”. If length of string “s1” is greater, put length of “s1” in “len”, else put length of string “s2” in “len”. It is required for strncmp function which has following syntax:
  • strncmp(,string2>,n); where n is number of characters to be compared.

  • Use strncmp function to compare s1, s2, and using “len” as n and store the result in variable “compare”.
  • Use if construct to check if “compare” is equal to 0, then display “Both strings are equal.".
  • else check if compare> 0, which will display “First string is greater than second.". Else display “First string is less than second."
  • Return and exit.

Blurred answer
Students have asked these similar questions
I need help to solve the following case, thank you
hi I would like to get help to resolve the following case
Could you help me to know  features of the following concepts: - defragmenting. - dynamic disk. - hardware RAID

Chapter 22 Solutions

C++ How to Program (Early Objects Version)

Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:9780357392676
Author:FREUND, Steven
Publisher:CENGAGE L