+ 1

can we used only if statement without else statement give example also

10th Jul 2016, 3:20 AM
piyush
6 odpowiedzi
+ 1
int x=3 if (x<5) {cout<<x is smaller}
10th Jul 2016, 3:36 AM
Vishal Meena
Vishal Meena - avatar
+ 1
Yes. int greatest(int x, int y){ if(x > y) return x; return y; } int main(){ int i; int j; cin >> i >> j; cout << greatest(i, j); return 0; }
10th Jul 2016, 3:45 AM
Tony Christopher
Tony Christopher - avatar
+ 1
yes , if can exist without else but vice-versa will give you an error
17th Jul 2016, 6:35 AM
Karan Luther
Karan Luther - avatar
0
Yes that's possible ! My friends have already provided examples
10th Jul 2016, 4:11 AM
Vex G Scarlet
Vex G Scarlet - avatar
0
yah thats very posible, bt in the case of else,we cannot use it without a coresponding if
13th Jul 2016, 7:11 AM
EARNEST KIAMBI KINYUA
EARNEST KIAMBI KINYUA - avatar
- 1
yes. try this one. #include<stdio> using namespace std; int main() { int a,b; cout<<"enter two values"; cin>>a>>b; cout<< (a>b)?a:b; return 0 }
10th Jul 2016, 9:53 AM
Praneethkumar Sajalu
Praneethkumar Sajalu - avatar