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
What Network does zoom run on? Does anyone use it (hint Hint)
rewona [7]

Answer:

  • The bandwidth used by Zoom will be optimized for the best experience based on the participant's' network. It will automatically adjust for 3G, WiFi, or wired environments.
  • i use g00gle meet bc zoom does not work on my school macbook...

Explanation:

:)

3 0
3 years ago
Suppose for the worst case, given input size n: Algorithm 1 performs f(n) = n2 + n/2 steps Algorithm 2 performs f(n) = 12n + 500
melomori [17]

Answer:

29

Explanation:

for n=28:

--------------

Algorithm 1 performs f(n) = n2 + n/2 = 28*28 + 28/2 = 798

Algorithm 2 performs f(n) = 12*28 + 500 = 836

for n=29

--------------

Algorithm 1 performs f(n) = n2 + n/2 = 29*29 + 29/2 = 855.5

Algorithm 2 performs f(n) = 12*29 + 500 = 848

so, for n=29, algorithm 2 will be faster than algorithm 1

6 0
3 years ago
Wardrobe engineering is important because
levacccp [35]

Answer:

The answer is "Option d"

Explanation:

The wardrobe engineering consists of choosing clothes that are so simple in design and better in the style that they are acceptable to the existing show-up and perfect for the future years. This design Originally coined Dressing for Confidence author John Molloy, which describe that clothes and accessories can also be used to create a certain picture, and wrong choices can be described as follows:

  • In option a, It's right, that we know about current fashions, but selecting suitable career apparel is not important, that's why it is incorrect.
  • In option b, It is wrong because whatever you wear is not to make choices of any sort.
  • In option c, It is wrong because it can't provide promotion.

3 0
3 years ago
Because assembly language is so close in nature to machine language, it is referred to as a ____________.
Travka [436]

Answer:

low-level language.

Explanation:

6 0
3 years ago
Read 2 more answers
Que es taylorismo plis
valina [46]

It is a method of work organization that seeks to increase productivity through the maximum division of functions, the specialization of work and the strict control of the time needed for each task.

7 0
3 years ago
Other questions:
  • Which of the following statements are true about the Internet?
    14·1 answer
  • What variation of a dictionary attack involves a dictionary attack combined with a brute force attack, and will slightly alter d
    9·1 answer
  • If you wanted to search for emails containing the word advanced and prevent emails containing the word new from appearing in the
    14·1 answer
  • The part of the computer that contains the brain, or central processing unit, is also known as the A. monitor. B. keyboard. C. m
    13·2 answers
  • How many parameters go into the function sum, and how many return values come out of the function sum? function sum(first, secon
    6·1 answer
  • Which of the following SQL statements will display all customers who have not recently placed an order? a. SELECT customer# FROM
    15·1 answer
  • The convergence of information technology and operations technology, offering the potential for tremendous improvements in effic
    14·1 answer
  • Write a program that first reads in the name of an input file, followed by two strings representing the lower and upper bounds o
    8·1 answer
  • Which is the following is a valid email id<br><br>​
    13·1 answer
  • What is the Cycle of Dependency?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!