Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Take A QuizChallenge yourself and boost your learning! Start the quiz now to earn credits.
Take A QuizUnlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
Take A QuizPlease log in to access this content. You will be redirected to the login page shortly.
LoginComputer Science Secondary School in Computer Science 1 year ago
ogram using Third Variable:ackage com.company; import java.util.SCANNER; public class main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("Enter 1st number: "); INT N = sc.nextInt(); System.out.println("Enter 2nd number: "); int n2 = sc.nextInt(); int n3; n3 = n; n = n2; n2 = n3; System.out.println("After swapping 1st number is: "+n); System.out.println("After swapping 2nd number is: "+n2); } }Your program without using Third Variable:package com.company; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner (System.in); System.out.println("Enter Number 1:"); int a = sc.nextInt(); System.out.println("Enter Number 2:"); int b = sc.nextInt(); if (a!=b){ a = a+b; b = a-b; a = a-b; } System.out.println("Numbers after swapping"); System.out.println("1st Number = "+a+" 2nd Number = "+b); } } I was not able to understand what you means by using COMMENT lines so I gave two programs.
Posted on 12 Aug 2024, this text provides information on Computer Science related to Secondary School in Computer Science. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.