Search This Blog

Sunday, 23 August 2020

Empty string function if else condition

 #include<iostream>

using namespace std;

int main()

{

string str1;

string str2="hello";

cout<<"enter the first string"<<endl;

cin>>str1;

cout<<"enter the second string:"<<endl;

cin>>str2;

if(str1.empty())

{

cout<<"string 1 is empty"<<endl;

}

else

{

cout <<"string is not empty"<<endl;

}

if(str2.empty())

{

cout<<"string 2 is empty."<<endl;

}

else

{

cout<<"strig 2 is not empty."<<endl;

}

return 0;

}


No comments:

Post a Comment

Search This Blog

Contact Form

Name

Email *

Message *

Popular Posts