C Program to Print First N Even Natural Numbers

C program to print first n even natural numbers; Through this tutorial, we will learn how to print first n (10, 100, 1000 .. N) even natural numbers in the c program with the help for loop and while loop

Algorithm and Program to Print First N Even Natural Numbers in C

Use the following algorithm and program to print first n (10, 100, 1000 .. N) even natural numbers in C:

  • Algorithm to Print First N Even Natural Numbers
  • C Program to Print First N Even Natural Numbers using For Loop
  • C Program to Print First N Even Natural Numbers using While Loop

Algorithm to Print First N Even Natural Numbers

Use the following algorithm to write a program to find and print first n(10, 100, 1000 .. N) even natural numbers; as follows:

  • Step 1: Start Program.
  • Step 2: Read the a number from user and store it in a variable.
  • Step 3: Find first n even natural number using for loop or while loop.
  • Step 4: Print first n even natural number.
  • Step 5: Stop Program.

C Program to Print First N Even Natural Numbers using For Loop

#include <stdio.h>

void main()
{
   int i,n;

   printf("Input number of terms : ");
   scanf("%d",&n);
   printf("\nThe even numbers are :");
   for(i=1;i<=n;i++)
   {
     printf("%d ",2*i);
   }

} 

The output of the above c program; as follows:

Input number of terms : 5
The even numbers are :2 4 6 8 10

C Program to Print First N Even Natural Numbers using While Loop

#include <stdio.h>

void main()
{
   int i,n;

   printf("Input number of terms : ");
   scanf("%d",&n);
   printf("\nThe even numbers are :");

   i = 1;

	while (i <= n)
	{
		printf("%d ", 2 * i);
		i++;
	}

} 

The output of the above c program; as follows:

Input number of terms : 5
The even numbers are :2 4 6 8 10 

Recommended C Programs

AuthorDevendra Dode

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

Your email address will not be published. Required fields are marked *