Fundamentals of Programming: Control Structures (if, else, elseif), Cheat Sheet of Programming Languages

Programming Language Slides In

Typology: Cheat Sheet

2020/2021

Uploaded on 10/16/2021

unknown-person-12
unknown-person-12 🇵🇰

3 documents

1 / 23

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Fundamentals of Programming
Lecture 4b: Control Structure
if else
if elseif else
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17

Partial preview of the text

Download Fundamentals of Programming: Control Structures (if, else, elseif) and more Cheat Sheet Programming Languages in PDF only on Docsity!

Fundamentals of Programming

Lecture 4 b: Control Structure if else if elseif else

Agenda

  • if else C++ statement
  • Nested if else C++ statement
  • if elseif else C++ statement

Relational Operators

Precedence of Operators

if Statement

  • “if statement” It is a program uses to compare the input data with a condition; to decide what to do if the input data matches the condition or not
  • “if” uses with first condition that evaluates to true
  • “else” come after “if” or “else if” it use without condition and it evaluates to false

if Syntax

Example

if…else Statement

  • If the condition is true − Program continues to next statement
  • If the condition is false − Program continues

if…else Statement

  • If the condition evaluates to true − The code inside the body of if is executed − The code inside the body of else is skipped from execution
  • If the condition evaluates to false − The code inside the body of else is executed − The code inside the body of if is skipped from execution

Example

if…else Statement Working

if…elseif…else Statement

Example