KEMBAR78
Some Icse Class 9 Programms | PDF
0% found this document useful (0 votes)
59 views1 page

Some Icse Class 9 Programms

This Java program defines a class called "sum" with a main method that takes an integer parameter n. It uses a for loop to iterate from 1 to n, printing each number and adding it to a running total s. After the loop, it prints the final sum.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views1 page

Some Icse Class 9 Programms

This Java program defines a class called "sum" with a main method that takes an integer parameter n. It uses a for loop to iterate from 1 to n, printing each number and adding it to a running total s. After the loop, it prints the final sum.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Class sum - s

1
2
3
4
5
6
7
8
9

10
11
12

class sum
{
public static void main(int n)
{
int i=0;
int s=0;
for(i=i;i<=n;i++)
{System.out.println(i);
s=s+i;
}System.out.println("sum="+s);
}
}

1/1

Sep 10, 2015 5:43:03 PM

You might also like