Can you please help me with this I'm stuck   #include #include #include #include using namespace std; bool functionWithArray(char s1[],char s2[]) {     int i = 0;     int c1=0,c2=0;     while(s1[i] != '\0'){         if(s1[i]!=' ')         {             c1++;         }          i++;     }     i = 0;      while(s2[i] != '\0'){         if(s2[i]!=' ')         {             c2++;         }          i++;     }     if(c1>s1;     cin>>s2;     if(functionWithArray(s1,s2)==1)         cout << "According to functionWithArray: c++programming is smaller than javaprogramming" << endl;      else         cout << "According to functionWithArray: c++programming is greater than javaprogramming" << endl;              if(functionWithPointers(&s1,&s2)==1)         cout << "According to functionWithPointers: c++programming is smaller than javaprogramming" << endl;      else         cout << "According to functionWithPointers: c++programming is greater than javaprogramming" << endl;        return 0; }   Output: For Inputs, c++programming javaprogramming

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
100%

Can you please help me with this I'm stuck

 

#include <cstdlib>
#include <iostream>
#include<cstring>
#include<string>
using namespace std;

bool functionWithArray(char s1[],char s2[])
{
    int i = 0;
    int c1=0,c2=0;
    while(s1[i] != '\0'){
        if(s1[i]!=' ')
        {
            c1++;
        }
         i++;
    }
    i = 0; 
    while(s2[i] != '\0'){
        if(s2[i]!=' ')
        {
            c2++;
        }
         i++;
    }
    if(c1<c2)
        return true;
    else
        return false;
}
bool functionWithPointers(string *s1,string *s2)
{
    int i = 0;
    int c1=0,c2=0;
    while(s1[i] != '\0'){
        if(s1[i]!=' ')
        {
            c1++;
        }
         i++;
    }
    i = 0; 
    while(s2[i] != '\0'){
        if(s2[i]!=' ')
        {
            c2++;
        }
         i++;
    }
    if(c1<c2)
        return true;
    else
        return false;
}
int main()
{       
    char s1[100];
    char s2[100];
    
    cout<<"Enter First String: "<<endl;
    cout<<"Enter Second String: "<<endl;
    cin>>s1;
    cin>>s2;
    if(functionWithArray(s1,s2)==1)
        cout << "According to functionWithArray: c++programming is smaller than javaprogramming" << endl; 
    else
        cout << "According to functionWithArray: c++programming is greater than javaprogramming" << endl;
        
    if(functionWithPointers(&s1,&s2)==1)
        cout << "According to functionWithPointers: c++programming is smaller than javaprogramming" << endl; 
    else
        cout << "According to functionWithPointers: c++programming is greater than javaprogramming" << endl;    
   return 0;
}

 

Output:

For Inputs,

c++programming
javaprogramming

 

 

 

Q x
> clang++-7 -pthread -std=c++17 -o main main.cpp
main.cpp:35:17: error: invalid operands to binary expression
('std::_cxx1l::string' (aka 'basic_string<char>') and
'char')
while (sl[i] != '\0'){
/usr/bin/../lib/gcc/x86_64–1inux-gnu/8/../../.././include/c++/8
/system error:319:3: note:
candidate function not viable: no known conversion from
'std::
_cxx11::string' (aka 'basic_string<char>') to
"const std::error code' for 1st arqument
operator!=(const error_code&
_lhs, const error_codes ...
/usr/bin/../1ib/gcc/x86_64-linux-gnu/8/../../././include/c++/8
/system error:323:3: note:
candidate function not viable: no known conversion from
'std::
_cxx11::string' (aka 'basic_string<char>') to
'const std::error code' for 1st argument
operator!=(const error code&
-
lhs, const error condit...
/usr/bin/../1ib/gcc/x86_64-linux-gnu/8/../../././include/c++/8
/system error:327:3: note:
candidate function not viable: no known conversion from
'std::
_cxx11::string' (aka 'basic_string<char>') to
'const std::error condition' for 1st argument
operator!=(const error condition&
lhs, const error_c...
/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c+/8
Transcribed Image Text:Q x > clang++-7 -pthread -std=c++17 -o main main.cpp main.cpp:35:17: error: invalid operands to binary expression ('std::_cxx1l::string' (aka 'basic_string<char>') and 'char') while (sl[i] != '\0'){ /usr/bin/../lib/gcc/x86_64–1inux-gnu/8/../../.././include/c++/8 /system error:319:3: note: candidate function not viable: no known conversion from 'std:: _cxx11::string' (aka 'basic_string<char>') to "const std::error code' for 1st arqument operator!=(const error_code& _lhs, const error_codes ... /usr/bin/../1ib/gcc/x86_64-linux-gnu/8/../../././include/c++/8 /system error:323:3: note: candidate function not viable: no known conversion from 'std:: _cxx11::string' (aka 'basic_string<char>') to 'const std::error code' for 1st argument operator!=(const error code& - lhs, const error condit... /usr/bin/../1ib/gcc/x86_64-linux-gnu/8/../../././include/c++/8 /system error:327:3: note: candidate function not viable: no known conversion from 'std:: _cxx11::string' (aka 'basic_string<char>') to 'const std::error condition' for 1st argument operator!=(const error condition& lhs, const error_c... /usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c+/8
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY