Computer Science, asked by ishita210, 1 year ago

wap in java to print sum of following series 1-3+5-7--- please reply fast


siddhartharao77: Only in java?
siddhartharao77: Okk

Answers

Answered by siddhartharao77
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!

siddhartharao77: Now its your turn to mark it as brainliest
Similar questions