0% found this document useful (0 votes)
25 views20 pages

DATA STRUCTURES Control Structures

The document reviews recursion concepts, including the Greatest Common Divisor (GCD) and control structures in programming. It discusses sequence and selection control structures, providing examples such as an even or odd checker in C++. Additionally, it covers switch-case statements and loops, along with exercises related to these topics.

Uploaded by

Zsar Dagumbal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views20 pages

DATA STRUCTURES Control Structures

The document reviews recursion concepts, including the Greatest Common Divisor (GCD) and control structures in programming. It discusses sequence and selection control structures, providing examples such as an even or odd checker in C++. Additionally, it covers switch-case statements and loops, along with exercises related to these topics.

Uploaded by

Zsar Dagumbal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Recursion review

Recursion terms (so far)


Greatest Common Divisor (GCD) using Recursion
Greatest Common Divisor (GCD) using Recursion
Control structures
objectives


Types:


1) Sequence Control Structure
Terms:
Example
2. Selection Control Structure
terms


Types of Selection in C++
Exercise: Even or Odd Checker
Output: #include <iostream>
using namespace std;
Enter an integer: 7
7 is an odd number. int main() {
int number;

cout << "Enter an integer: ";


cin >> number;

If (______________________________
______________________________
______________________________
______________________________
return 0;
}
solution
#include <iostream>
using namespace std;

int main() {
int number;

cout << "Enter an integer: ";


cin >> number;

if (number % 2 == 0) {
cout << number << " is an even number." << endl;
} else {
cout << number << " is an odd number." << endl;
}
return 0;
}
switch-case Statement
Loops (Iteration)
Loop exercise
end

You might also like