You are on page 1of 2

• For Loop

#include <iostream.h>

int main() {

for (int i = 1; i <= 5; i++)

cout << i << " ";

return 0;

• Switch case:

#include <iostream.h>

int main() {

int day = 4;

switch (day) {

case 1:

cout << "Monday";

break;

case 2:

cout << "Tuesday";

break;

case 3:

cout << "Wednesday";

break;

case 4:

cout << "Thursday";

break;

case 5:

cout << "Friday";

break;

case 6:

cout << "Saturday";


break;

case 7:

cout << "Sunday";

break;

return 0;

• If Else:

#include <iostream.h>

using namespace std;

int main() {

int number;

cout << "Enter an integer: ";

cin >> number;

if (number >= 15) {

cout << "You entered a number is greater than 15: " << number << endl;

else {

cout << "You entered a number is less than 15: " << number << endl;

cout << "This line is always printed.";

return 0;

You might also like