Get Off-Campus Placement Jobs Info !!!
Programs asked in Mettl Coding Round
Click To Practce List of Programs asked in Nagarro !!!

Program Discussion :: Basics

Home > Programs > Basics

9 / 248

Write a program to print alternate even numbers(2,6,10,14,18....).

Answer:

import java.util.*;

public class AlternateEven 
{
    public static void main(String[] args)
    {    
        Scanner sc=new Scanner(System.in);
        System.out.println("Enter the range: ");
        int n=sc.nextInt();
        System.out.println("Alternate even numbers upto "+n+" are: ");
        for(int i=2;i

Asked In :: Syntel Inc.

Post Your Answer Here:

Language:

Post Your Reply Here: