C++ Program to Print First 10 Even Natural Numbers

Howdy readers, today you will learn how to write a C++ program to print the first 10 even natural numbers.

The even natural numbers are the numbers that are even, exactly divisible by 2, and belong to the set N. The first 10 even natural numbers are = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20].

This tutorial prints the first 10 even natural numbers using the following approaches:

  1. Using For Loop
  2. Using While Loop
  3. Using Do While Loop

So, without any delay, let’s begin this tutorial.

C++ Program to Print First 10 Even Natural Numbers

C++ Program

// C++ Program to Print First 10 Even Numbers Using For Loop
#include <iostream>
using namespace std;

int main(){
    int i;
    
    cout << "The first 10 Even Natural Numbers are:-" << endl;
    for (i = 1; i <= 10; i++){
        cout << i * 2 << " ";
    }
    
    return 0;
}

Output

The first 10 Even Natural Numbers are:-
2 4 6 8 10 12 14 16 18 20 
C++ Program to Print First 10 Even Natural Numbers

Explanation

    for (i = 1; i <= 10; i++){
        cout << i * 2 << " ";
    }

We start the for loop iteration from i = 1 and continue until i <= 10.

  • 1st For Loop Iteration (i = 1) = i * 2 = 1 * 2 = 2
  • 2nd For Loop Iteration (i = 2) = i * 2 = 2 * 2 = 4
  • 3rd For Loop Iteration (i = 3) = i * 2 = 3 * 2 = 6
  • 4th For Loop Iteration (i = 4) = i * 2 = 4 * 2 = 8
  • 5th For Loop Iteration (i = 5) = i * 2 = 5 * 2 = 10
  • 6th For Loop Iteration (i = 6) = i * 2 = 6 * 2 = 12
  • 7th For Loop Iteration (i = 7) = i * 2 = 7 * 2 = 14
  • 8th For Loop Iteration (i = 8) = i * 2 = 8 * 2 = 16
  • 9th For Loop Iteration (i = 9) = i * 2 = 9 * 2 = 18
  • 10th For Loop Iteration (i = 10) = i * 2 = 10 * 2 = 20
  • 11th For Loop Iteration (i = 11), here the condition i <= 10 becomes False. Therefore, the loop terminates, and we get all the first 10 even natural numbers printed on the screen.

C++ Program to Print First 10 Even Natural Numbers Using While Loop

C++ Program

// C++ Program to Print First 10 Even Natural Numbers Using While Loop
#include <iostream>
using namespace std;

int main(){
    int i = 1;
    
    cout << "The first 10 Even Natural Numbers are: " << endl;
    while (i <= 10){
        cout << i * 2 << " ";
        i++;
    }
    
    return 0;
}

Output

The first 10 Even Natural Numbers are: 
2 4 6 8 10 12 14 16 18 20 
C++ Program to Print First 10 Even Natural Numbers Using While Loop

C++ Program to Print First 10 Even Natural Numbers Using Do While Loop

C++ Program

// C++ Program to Print First 10 Even Natural Numbers Using Do While Loop
#include <iostream>
using namespace std;

int main(){
    int i = 1;
    
    cout << "First 10 even natural numbers:-" << endl;
    do{
        cout << i * 2 << " ";
        i++;
    } while (i <= 10);
    
    return 0;
}

Output

First 10 even natural numbers:-
2 4 6 8 10 12 14 16 18 20 
C++ Program to Print First 10 Even Natural Numbers Using Do While Loop

Conclusion

Today you learned how to write a C++ program to print the first 10 even natural numbers.

If you have any queries regarding the tutorial, comment down your questions in the comment section.

Thanks for reading.

Happy Coding!!

Also Read:

Leave a Comment