1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Sloan [31]
3 years ago
14

There are two String variables, s1 and s2, that have already been declared and initialized. Write some code that exchanges their

values. Declare any other variables as necessary.
Computers and Technology
2 answers:
Ivan3 years ago
8 0

Answer:

//here is code in java.

import java.util.*;

class Solution

{

// main method of class

public static void main (String[] args) throws java.lang.Exception

{

   try{

    // declare an initialize first string variables

     String st1="hello";

     // declare an initialize first string variables

     String st2="world";

     // create another string variable

    String st3;

    // exchange the value of both string variables

    st3=st1;

    st1=st2;

    st2=st3;

    System.out.println("value of first String after exchange: "+st1);

    System.out.println("value of second String after exchange: "+st2);

   }catch(Exception ex){

       return;}

}

}

Explanation:

declare and initialize two string variables.Create another string variable "st3". first assign value of "st1" to "st3" after then value of "st2" to "st1" and then  assign value of "st3" to "st2". This will exchange the values of both the string.

Output:

value of first String after exchange: world

value of second String after exchange: hello

Lunna [17]3 years ago
5 0

Answer:

The following are the code

string s1="san";

string s2="ran";

string temp; // other variable

temp=s1;// statement 1

s1=s2;// statement 2

s2=temp;//statement 3

Explanation:

In this code we declared two string s1 , s2 and initialized them after that we declared an extra variable temp .

The statement 1  temp=s1   means that temp will store the value of s1 i.e "san". so temp="san";

The second statement 2  s1=s2   means that s1 will store the value of s2

i.e s1="ran";

The third statement 3 s2=temp means that s2 will store the value of temp.

i.e s2="san"

we see that s1 and s2 will exchange their value

Following are the code in c++

#include <iostream> // header file

#include<string>

using namespace std;

int main()// main function

{

string s1="san";

string s2="ran";

string temp;

cout<<"before exchange:"<<s1<<s2<<endl; // display before exchanging the value

temp=s1;

s1=s2;

s2=temp;

cout<<"after exchange:"<<s1<<s2<<endl;// display after exchanging the value

return 0;

}

Output:

before exchange:sanran

after exchange:ransan

You might be interested in
A Python data model defining the state of a game for Tic-Tac-Toe. You must fully describe the notion of a state of the game, lim
Artist 52 [7]

Answer:

Check the explanation

Explanation:

Here in this game of Tic-Tac-Toe, it is using the TPGE engine which is a Tiny Python Game Engine. Let's talk about its functions like:-

def image_type(img): In this function, it is simply taking image as a parameter and returning its object type like DISC if the image is in graphical form, TEXT if it is a string, and LINE if it is other than the mentioned object.

def convert_image(img):  In this function, it is simply taking image as a parameter and returning an equivalent graphical object as understood by John Zelle's. Mainly comparing for three things in this function and those are: if image equals to DISC then it is calling convert_circle(function), if image equals to LINE then it is calling convert_line(function), and if image equals to TEXT then it is calling convert_text(function),

def convert_circle(x): This function takes a list( a group of values) and makes a circle at the center of the window and the circle's radius is coming from the list.

convert_text, convert_line, convert_circle are only creating text, line, and circle and then returning it.

def graphical_elements(images): This function is taking image as a parameter and then extracting shape and color from the image and then calling convert_image(shape) and convert_type(shape) and it gives us graphic and kind respectively. Now it is checking whether kind equals to DISC If yes then filling color on the window else, setting the outline of the window

def run(): Here it is finally running the game with required parameters, the whole game is continously running under the while loop.

That's all

8 0
3 years ago
one day when rahul went to his computer lab and saw that all the computers were connected to a single printer and whoever is giv
amm1812

Explanation:

you can connect multiple PCs to the wireless printer and print your documents from each one of them as long as the printer can be connected to the same network . You need the disc that came with the wireless printer to install the correct drivers on your computers and laptops.

hope it helps ( brainleist please )

7 0
2 years ago
What is the difference between margin and padding property?
VMariaS [17]

Answer:

Margin is applied to the outside of your element hence affecting how far your element is away from other elements.

Padding is applied to the inside of your element hence affecting how far your element's content is away from the border.

Explanation:

Hope it helps!!!

6 0
1 year ago
Two different applications that make use of the barcode
jeyben [28]
Library books and items bought in stores are 2 different applications that make use of barcodes.
8 0
3 years ago
The ___________ button represents the start of a hyperlink in Table of contents.
zubka84 [21]

Answer:

An LS button

Explanation:

It appears on the (structure line 3)on the structure line, place your cursor in the <u>whi</u><u>te</u> field to the right of the E button (Recall that the E button represent the entry test).

3 0
3 years ago
Other questions:
  • True or false: when considering data backups, it is most important to verify that the integrity of the backup file or data is va
    9·1 answer
  • Q1: what is significant about the contents of the destination address field?
    12·2 answers
  • An iframe is an inline table for a website. True False i need an answer fast
    15·1 answer
  • A(n) monitoring vulnerability scanner is one that listens in on the network and determines vulnerable versions of both server an
    7·1 answer
  • The following code processes a file containing five positive numbers. What will the variable $result contain after the code is e
    10·1 answer
  • Lexi wants to buy a $300 painting. when she gets to the store, she finds that it is on sale for 40% off. how much does Lexi spen
    10·1 answer
  • _____ interviews rely on scenarios and reflections to evaluate an applicant’s skill set.
    9·2 answers
  • Cn someone help me plz
    11·1 answer
  • I need some help-
    15·1 answer
  • write a program that computes an integer's checksum. to compute the checksum, break the integer into its constituent
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!