Write the java code to print the sum of 1 to 5 natural numbers
Answers
Answered by
5
public class Shardul {
void main() {
int i,s=0;
for( i=1;i<=5;i++) {
s=s+I ;
}
System.out.println("The sum is: " + s );
}
}
Similar questions
English,
6 months ago
Math,
6 months ago
Computer Science,
6 months ago
Physics,
1 year ago
French,
1 year ago
Social Sciences,
1 year ago
Social Sciences,
1 year ago
Social Sciences,
1 year ago