Computer Science, asked by aaditee187, 1 year ago

Write the java code to print the sum of 1 to 5 natural numbers​

Answers

Answered by shardul1925
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