given an integer n find and print the sum of numbers from 1 to n use while loop only
Answers
Answered by
5
Answer:
n = input(int("enter the value"))
sum = 1+n*1
for i in sum
print(sum)
Explanation:
Answered by
0
Answer:
import java.util.Scanner;
class all
{
Scanner sc=new Scanner(System.in);
int sum;
public void main(String args[])
{
System.out.println("enter the number you want the sum of");
int n=sc.nextInt();
int a=1;
while(a<=n)
{
sum=sum+a;
a++;
}
System.out.println(sum);
}
}
Explanation:
Similar questions