Multiple Selections!!! NESTED IF - PowerPoint PPT Presentation

1 / 6
About This Presentation
Title:

Multiple Selections!!! NESTED IF

Description:

case value1: statement1. break; case value2: statement 2. break; default : statements. So when do I use SWITCH and when do I use IF...ELSE ... – PowerPoint PPT presentation

Number of Views:32
Avg rating:3.0/5.0
Slides: 7
Provided by: olddominio
Learn more at: https://www.cs.odu.edu
Category:

less

Transcript and Presenter's Notes

Title: Multiple Selections!!! NESTED IF


1
Multiple Selections!!! NESTED IF
What if I have multiple selections!!! Look at the
syntax below if (condition) if
(condition) else else if
(condition) else
Lets do Example alphaone
2
Multiple Selections SWITCH CASE
Wooffff!!! That previous problem was a bit
confusing!!! So theres another way!!!! switch
(expression) case value1 statement1 break ca
se value2 statement 2 break .. .. default
statements So when do I use SWITCH and when
do I use IFELSE Notice in SWITCH ? expression is
not a logical condition Notice in IF ? condition
is a logical Lets do example alphatwo
3
FUNCTIONS
Int main() coutltlthello coutltlthi coutltlthow
coutltltare coutltltyou? coutltlthello cout
ltlthi coutltlthow coutltltare coutltltyou?
Int main() testfunction() Int
testfunction() coutltlthello coutltlthi coutltlt
how coutltltare coutltltyou?
Which is better??? You decide????
4
Value Returning functions
Functions
VOID functions
Order of the three parts FUNCTION Header Int
main() .. Function call .. Function()
  • A function contains the following
  • A function header
  • A function call
  • The function..

VOID FUNCTIONS
Has no return value. Its all in the example
1.Lets do it A new hello world program.
5
Question Write a function called ADD. It takes
the input of two numbers and Adds them. Print
the result.
Value Returning Functions
General syntax FunctionType functionName
(formal parameters) Statements Return
? Formal paramenter ? dataType identifier,
dataType identifier,.
6
Function call
functionName (actual parameter list) Actual
parameter ? variable, variable,. EXAMPLE
3 Question Write a Program that takes the input
of three numbers and Write a function that finds
the largest of the three numbers. The function
Should take the three numbers as parameters and
return the largest of the Three numbers
Write a Comment
User Comments (0)
About PowerShow.com