Code Box
-------------------
/*Program for function with return type and with arguments*/
class funwithr
{
public static void main(String r[])
{
int total,a,b;
a=Integer.parseInt(r[0]);
b=Integer.parseInt(r[1]);
System.out.print("\nSum of two number:");
total=sum(a,b);
System.out.print(total); //Function call
}
public static int sum(int a,int b) //Function Definition
{
int c;
c=a+b;
return c;
}
}
0 comments:
Post a Comment