5. a. Write a program in Java to store 5 in G and 7 in H respectively. Print the original value as
[6]
well as the swapped value of G and H separately by using a third variable J?
Answers
/*
Project Type: Brainly Answer
Date Created: 10-02-2021
Date Edited Last Time: ---NIL---
Question Link: https://brainly.in/question/34936336
Question: Write a program in Java to store 5 in G and 7 in H respectively.
Print the original value as well as the swapped value of G and H
separately by using a third variable J.
Program Created By: atrs7391
Programming Language: Java
Language version (When program created or last edited): jdk-15.0.2
*/
package Brainly_Answers;
public class Swapping_Two_Number_with_Third_Variable {
public static void main(String[] args) {
byte G = 5, H = 7, J;
//declaring and initialising the variables
System.out.println("Value of G before swapping: "+G);
System.out.println("Value of H before swapping: "+H);
//printing the values before swapping
J = G;
G = H;
H = J;
//swapping the values
System.out.println("Value of G after swapping: "+G);
System.out.println("Value of H after swapping: "+H);
//printing the values after swapping
}
}
Answer:
hey nobilian doing cheating in comp exam