write a code in jsp to swap two numbers?

Answers were Sorted based on User's Feedback



write a code in jsp to swap two numbers?..

Answer / ritesh prabhu

<%@ page language="java" %>
<html>
<head>
<TITLE>Swap Numbers </TITLE>
</head>
<body bgcolor="#9999FF" >
<FONT SIZE=4 COLOR=white><U>Program to Swap 2
Numbers</U></FONT><BR>
<%
int i=1;
int j=2;
out.print("<FONT SIZE=3 COLOR=white>");
out.println("Before swapping i="+i+" j="+j);
out.println("<br>");
int temp=i;
i=j;
j=temp;
out.println("After swapping i = " + i + " j = " + j);
out.print("</Font>");
%>
</body>
</html>

Is This Answer Correct ?    33 Yes 10 No

write a code in jsp to swap two numbers?..

Answer / lipu

a,b
a=a+b;
b=a-b,
a=a-b;
write them in scriplet and declaration.

Is This Answer Correct ?    21 Yes 4 No

write a code in jsp to swap two numbers?..

Answer / sandip

Where are the textboxes to swap the nos.........

Is This Answer Correct ?    11 Yes 2 No

write a code in jsp to swap two numbers?..

Answer / rakesh.fanu

class SwapingTest
{
public static void main(String xx[])
{
int a,b,temp;
a=10;
b=20;
System.out.println("Before Swaping :-");
System.out.println("Value a is "+a);
System.out.println("Value b is "+b);
temp=b;
b=a;
a=temp;
System.out.println("After Swaping :-");
System.out.println("Value a is "+a);
System.out.println("Value b is "+b);
}
}

Is This Answer Correct ?    11 Yes 5 No

write a code in jsp to swap two numbers?..

Answer / yadhunandan.t

wap to swap two numbers without using third variable.
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b;
clrscr();
printf("enter the value of a & b");
scanf("%d %d",&a,&b);
printf("\n\n\n before swaping");
printf("\n\ta:%d",a);
printf("\n\tb:%d",b);
a=a+b;
b=a-b;
a=a-b;
printf("\n\n\n after swaping");
printf("\n\ta:%d",a);
printf("\n\tb:%d",b);
getch();
}

Is This Answer Correct ?    5 Yes 3 No

write a code in jsp to swap two numbers?..

Answer / p.a.v.k.prasad

Swapping the two nubers without using third variable.

int a,b;

b=a+b;
b=a-b;
a=a-b;

try it.

Is This Answer Correct ?    3 Yes 5 No

write a code in jsp to swap two numbers?..

Answer / vishal

<%@ page language="java" %>
<html>
<head>
<TITLE>Swap Numbers </TITLE>
</head>
<body bgcolor="red" >
<FONT SIZE=4 COLOR=white><U>Program to Swap 2
Numbers</U></FONT><BR>
<%
int a=1;
int b=3;
out.print("<FONT SIZE=3 COLOR=white>");
out.println("the number is swapping "+a+"+b);
out.println("<br>");
int b=a+b;
int b=a-b;
int a=a-b;

out.println("the swapped number is a = " + a + " b = " + b);
out.print("</Font>");
%>
</body>
</html>

Is This Answer Correct ?    3 Yes 6 No

Post New Answer

More Java Related AllOther Interview Questions

What is jar file in java?

0 Answers  


Can I use openjdk for commercial?

0 Answers  


What is mdb in java?

0 Answers  


What does public static void main(string[]) mean?

0 Answers  


In java what is the difference between sleep() and wait() .

0 Answers   Amazon,


What is an entity in java?

0 Answers  


Name primitive java types.

0 Answers  


Explain the reason for each keyword of public static void main(string args[])?

0 Answers  


How do I open my java console?

0 Answers  


What is type inference? Is type inference available in older versions like java 7 and before 7 or it is available only in java se 8?

0 Answers  


explain how java se 8 data and time api solves issues of old java date api?

0 Answers  


What is a service layer in java?

0 Answers  


Categories