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
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++
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
Step by step
Solved in 2 steps