From the course: COBOL Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Conditional expressions

Conditional expressions - COBOL Tutorial

From the course: COBOL Essential Training

Start my 1-month free trial

Conditional expressions

- [Instructor] We often have to make decisions every day. For example, if it's raining, then I want to take an umbrella. This is an example of a conditional expression, which evaluates to either true or false. It's either raining, or it's not. Programming languages work in a similar fashion. They use an if statement. If some condition is true, then execute some statement. Sometimes we want to include an else. If some condition is true, otherwise, execute some other statements. In COBOL, we don't use curly brackets to denote the start and stop of a block of code, but we can use an N verb to help identify when an if statement ends. We can use an "if" and an "else," and then an "end-if." Not only does this help make sure that we're ending at the right spot, it also makes it easier to read. COBOL also allows for nested if statements. This is where an end-if really comes in handy. Other conditional expressions in COBOL…

Contents