Computer Science, asked by NU2310, 10 months ago

In java ,3rd program please help

Attachments:

Answers

Answered by srinitishsri
1

//USED FUNCTION WITH PARAMETERS

import java.io.*;

import java.util.*;

class Q_3

{

public void dis(int m,int n)

{

int sum1=0,sum2=0;

for(int x=m;x<=n;x++)//both inclusive

{

if(x%2==0)

{

sum1=sum1+x;

}

else

{

sum2=sum2+x;

}

}

System.out.println("Sum of even- "+sum1);

System.out.println("Sum of odd- "+sum2);

}

}



NU2310: thank you
Similar questions