Code Box
--------------------------------------------
/*program to swap two values using third variable */
import java.io.*;
class swap
{
public static void main(String x[]) throws IOException
{
int a,b,temp;
BufferedReader obj=new BufferedReader(new InputStreamReader(System.in));
System.out.print("\nEnter two numbers :");
System.out.print("\nEnter first number a= ");
a=Integer.parseInt(obj.readLine());
System.out.print("\nEnter second number b= ");
b=Integer.parseInt(obj.readLine());
System.out.print("\nValues before swapping a= "+a+" & b= "+b);
temp=a; //swapping
a=b;
b=temp;
System.out.print("\nValues after swapping a= "+a+" & b= "+b);
}
}
Bro ur program is awesome it really helped me but can I pls. tell me why have I not used PRINTLN anywhere
ReplyDeleteThis comment has been removed by the author.
DeleteThank you Ajay Nagarkar, for your valuable comment.
DeleteAnd answer for your question why I didn't use println() and use print() is here
http://codeboxjava.blogspot.in/2016/05/difference-between-println-and-print-in.html
please go through it. I explained it for you. And if you get any problem please feel free to comment back.
This comment has been removed by the author.
ReplyDeleteThank you Ajay Nagarkar, for your valuable comment.
DeleteAnd answer for your question why I didn't use println() and use print() is here
http://codeboxjava.blogspot.in/2016/05/difference-between-println-and-print-in.html
please go through it. I explained it for you. And if you get any problem please feel free to comment back.