Bu yazımızda C++ iç içe geçmiş if ifadesini gösteren bir örnek paylaşıyoruz.
#include <iostream>
using namespace std;
int main() {
/* nested if else statement */
int a;
cout << "Enter a positive integer number: ";
cin >> a;
if (a < 20) {
cout << "a is less than 20\n";
if (a < 10)
cout << "a is less than 10\n";
else
cout << "a is not less than 10\n";
} else {
if (a == 20) {
cout << "a is equal to 20\n";
} else
cout << "a is greater than 20\n";
}
return 0;
}
+ There are no comments
Add yours