wap in java to print sum of following series 1-3+5-7--- please reply fast
siddhartharao77:
Only in java?
Answers
Answered by
2
class BasicProgram
{
public static void main(String args[])
{
int brainly = -1;
int user = 1;
for(int i=0;i<10;i++)
{
brainly=brainly+2;
user+= 1;
if(brainly%2==0)
{
System.out.println(brainly);
}
else
{
System.out.println(-brainly);
}
}
}
}
Hope this helps!
{
public static void main(String args[])
{
int brainly = -1;
int user = 1;
for(int i=0;i<10;i++)
{
brainly=brainly+2;
user+= 1;
if(brainly%2==0)
{
System.out.println(brainly);
}
else
{
System.out.println(-brainly);
}
}
}
}
Hope this helps!
Similar questions