From 34efaa32556bfc63df2790f63080c2e684464c02 Mon Sep 17 00:00:00 2001 From: Satwik-ERROR404 Date: Sun, 20 Oct 2019 22:53:26 +0530 Subject: [PATCH] modified if-else statement using another condition --- string.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/string.cpp b/string.cpp index 1f79de0..8e19ce6 100644 --- a/string.cpp +++ b/string.cpp @@ -8,16 +8,23 @@ int main() string s, s1; s = "HELLO"; s1 = "HELLO"; + int check1=0,check2=0; if(s.compare(s1) == 0) + { + check1=1; cout << s << " is equal to " << s1 << endl; - else + } + if(check1==0) cout << s << " is not equal to " << s1 << endl; s.append(" WORLD!"); cout << s << endl; printf("%s\n", s.c_str()); if(s.compare(s1) == 0) + { + check2=1; cout << s << " is equal to " << s1 << endl; - else + } + if(check2==0) cout << s << " is not equal to " << s1 << endl; return 0; -} \ No newline at end of file +}