0% found this document useful (0 votes)
4 views3 pages

JAVA5 Priyanka

Uploaded by

Priyanka Thadke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views3 pages

JAVA5 Priyanka

Uploaded by

Priyanka Thadke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Name: Priyanka Khandu Thadke

Class:CO4I(A) Roll no:85

Practical no:- 5 Develop a program to demonstrate use of looping statement ‘For’.

Program code:

Q.)Develop a program to print command line argument using for loop.

class Abc

public static void main(String args[])

int sum=0;

for(int i=0;i<args.length;i++)

sum=sum+Integer.parseInt(args[i]);

System.out.println("Sum="+sum);

Output:

Practical Related Questions:-

Q.3) write a for loop to increment index variable by 2 in each iteration.

class Nums

public static void main(String args[])


{

for(int i=1;i<11;i=i+2)

System.out.println("I="+i);

Output:

Exercise:

Q.1)Write any program using if condition with for loop.

class Even

public static void main(String args[])

System.out.println("Even Numbers are:");

for(int n=1;n<=50;n++)

if(n%2==0)

System.out.println(+n);

}
}

OutPut:

You might also like