Everything kinda boring here ..
W.A.P. to print the sum of series
1+2+3+4+5+.....nth terms
[ no copy from Google ,else i will report to mod. ]
Answers
Using JAVA:
It goes like:
import java.util.Scanner;
public class brainly
{
public static void main(String[] args)
{
Scanner scan=new Scanner (System.in);
System.out.print("Enter the value of n: ");
double n=scan.nextInt();
int sum=0;
for (int i=1;i<n+1;i++)
{
sum = sum+i;
}
System.out.println(sum);
}
}
Consider the attachment if you're having trouble understanding statement.
![](https://hi-static.z-dn.net/files/d29/57c21e71d669f916a63c1804ad83f0eb.jpg)
![](https://hi-static.z-dn.net/files/da8/815a71de490258c868b0797e0ca4d541.jpg)
Question:-
- WAP to print the sum of the series
1+2+3+4+...+nth term
Code Language:-
- Not mentioned
- Done In Java, Python and QBASIC
Java Code:-
package Coder;
import java.util.*;
public class SerSsum
{
public static void main(String ar[])
{
System.out.println("Enter no. of terms") ;
int n=sc.nextInt() ;
int s=0;
for(int I=1;I<=n;I++)
{
s+=I;
}
System.out.println("Sum="+s);
}
}
•Output attached
Python Code:-
n=(int)(input("Enter no. of terms"))
for I in range(1,n+1):
s=s+I
print("SUM=",s)
QBASIC Code:-
CLS
PRINT "ENTER A NUMBER"
INPUT N
FOR I=1 TO N
S=S+I
NEXT I
PRINT "SUM="+S
END
![](https://hi-static.z-dn.net/files/d04/104000fa4d563409bebabaf96cf0261d.jpg)
![](https://hi-static.z-dn.net/files/d60/3cf6e876802de02d701dd10fa392e34a.jpg)