[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

Program Discussion :: Basics

Home > Programs > Basics

305 / 279

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: