WAP to print the series
1)1/2.3+2.1/2.3+3.2/3.4 + n
Answers
Answered by
2
import java.io.*;
class quesans
{ public static void main()throws IOException
{
DataInputStream ak =new DataInputStream(System.in);
System.out.println("ENTER NUMBER TILL U WANT SUM OF SERIES ");
int n=Integer.parseInt(ak.readLine());
double sum=0 ,cons= 2.3; for(int i=1;i<=n;i++) {
sum+=i/cons; cons=cons + 1.1; }
System.out.println("SUM Is="+sum);
}}
class quesans
{ public static void main()throws IOException
{
DataInputStream ak =new DataInputStream(System.in);
System.out.println("ENTER NUMBER TILL U WANT SUM OF SERIES ");
int n=Integer.parseInt(ak.readLine());
double sum=0 ,cons= 2.3; for(int i=1;i<=n;i++) {
sum+=i/cons; cons=cons + 1.1; }
System.out.println("SUM Is="+sum);
}}
ABHAYSTAR:
Nice answer bro :)
Answered by
14
ANSWER
....................
int x = 2;
int y = 1;
int z = 100;
/*
or use cin to get input
, this will be our 'n' aka the max range
*/ int sum = 0;
while ( y < z)
{
if ( y%x != 0)
{
sum = sum + y;
}
else
{
sum = sum - y;
}
y++;
}
cout << sum;
....................
int x = 2;
int y = 1;
int z = 100;
/*
or use cin to get input
, this will be our 'n' aka the max range
*/ int sum = 0;
while ( y < z)
{
if ( y%x != 0)
{
sum = sum + y;
}
else
{
sum = sum - y;
}
y++;
}
cout << sum;
Similar questions