If, Else-If and Else Statements
Let me present to you a program using the selection statements: if, if-else and else statements. These kind of statements are used when there's a condition or set of conditions that needs to be evaluated first in order to proceed and execute certain statements within a program.
/* If, Else-If and Else Selection */ #include <iostream> using namespace std; int main(void) { int age; char pause; cout << "Enter your age: "; cin >> age; //check the age entered if (age == 18) { cout << "You are 18 years old!" << endl; } else if (age > 18) { cout << "You are older than an 18 year old!" << endl; } else { cout << "You are below 18 years old!" << endl; } cin >> pause; return 0; }
2 comments
Write commentsnice article for beginners.thank you.
Replywelookups C++
javacodegeeks
From what I know, such functions in programming languages are the absolute basis. Anyway, I'm very happy to use applications that work in the cloud because it seems to me the most comprehensive solution. I value programs from the company grapeup.com/ and I am of the opinion that such solutions in the cloud are very good.
Reply