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
dedylja [7]
3 years ago
11

Write a program whose input is two integers and whose output is the two integers swapped. Ex: If the input is: 38 then the outpu

t is: 83 Your program must define and call a function. SwapValues returns the two values in swapped order. void SwapValues (int* userVali, int* userVal2) LAB ACTIVITY 6.22.1: LAB: Swapping variables 22.1. LAB 0/10 ] main.c Load default template... #include /* Define your function here */ int main(void) { Ovo AWN /* Type your code here. Your code must call the function. */ return 0; 10 }
Computers and Technology
1 answer:
Likurg_2 [28]3 years ago
6 0

Answer:

Following are the program in the C++ Programming Language.

#include <iostream>

using namespace std;

//define function for swapping

void SwapValues(int* userVal1,int* userVal2){  

//set integer variable to store the value

int z = *userVal1;

//interchange their value

*userVal1 = *userVal2;  

//interchange their value

*userVal2 = z;

}

//define main method

int main()

{    

//declare variables

int x,y;

//get input from the user

cin>>x>>y;

//Call the method to swap the values

SwapValues(&x,&y);

//print their values

cout<<x<<" "<<y;

return 0;

}

<u>Output</u>:

3 8

8 3

Explanation:

<u>Following are the description of the program</u>.

  • Firstly, we define required header file and function 'SwapValues()', pass two pointer type integer variables in argument that is 'userVal1' and 'userVal2'.
  • Set integer data type variable 'z' and initialize the value of 'userVal1' in it, then initialize the value of 'userVal2' in 'userVal1' and then initialize the value of 'z' in 'userVal2'.
  • Finally, define the main method in which we set two integer type variables and get input from the user in it then, call and pass those variables and print it.
You might be interested in
You type. The word "weather" when you ment "whether" when will the writer or word flag this as a misspelling or a grammar proble
xxTIMURxx [149]
Most likely depends on the situation
8 0
3 years ago
Steve, an HR manager for IBM, must decide what positions the firm should fill in the next 6 months, which means Steve is current
Katyanochek1 [597]

Answer:

personnel planning

Explanation:

Steve, an HR manager for IBM, must decide what positions the firm should fill in the next 6 months, which means Steve is currently working on personnel planning.

4 0
3 years ago
Brainly Question 2.0
Klio2033 [76]

Answer:

Depends, but most of the time definitly  

:)

3 0
3 years ago
Feistel proposed that we can approximate the ideal block cipher by utilizing the concept of a __________ cipher, which is the ex
sweet-ann [11.9K]

Answer:

product cipher Is the answer

5 0
2 years ago
Read 2 more answers
Write a program for a grocery store to calculate the total charge for customers. In the main: Your program should ask customer t
gavmur [86]

Answer:

Hello Joelwestwood! This is a good question to check your knowledge of subrountines and Arrays. Please find the implementation with the explanation below.

Explanation:

The solution can be implemented in a number of languages including C++, Java and Python to name a few. Though the implementation language is not specified in the question, i'll provide you the implementation code in Python and also in Java. Java implementation is a little complex because we need to define an array size to be able to add items to it, whereas Python allows us more flexibility by allowing dynamic size of Array.

JAVA IMPLEMENTATION

import java.util.Scanner;

import java.util.Arrays;

class TotalCharge {

 private static int[] price_array = new int[1];

 public void FillPriceArray(int price) {

   if (price_array.length == 1) {

     price_array[0] = price;

   } else {

     price_array = new int[price_array.length + 1];

     price_array[price_array.length + 1] = price;

   }

 }

 public int[] get_price_array() {

   return price_array;

 }

 public static void main(String args[]) {

   System.out.println("Please enter the total number of items to purchase: ");

   Scanner scan = new Scanner(System.in);

   int price = scan.nextInt();

   if (price <= 20) {

     System.out.println("Items being purchased are less than 20");

   } else {

     System.out.println("Items being purchased are more than 20");

   }

   TotalCharge itemsTotal = new TotalCharge();

   itemsTotal.FillPriceArray(price);

   System.out.println(Arrays.toString(itemsTotal.get_price_array()));

 }

}

PYTHON IMPLEMENTATION

calculate_total_charge.py

def FillPriceArray(price):

 price_array.append(price)

price_array = []

price = raw_input("Please enter the total number of items to purchase: ")

try:

 price = int(price)

 if price <= 20:

   print("Items being purchased are less than 20")

 else:

   print("Items being purchased are more than 20")

 FillPriceArray(price)

 print(price_array)

except ValueError:

 print("Invalid input! Exiting..")

8 0
3 years ago
Other questions:
  • What might happen if a computer has too many applications running at one time?
    15·1 answer
  • Match the risk mitigation techniques with their characteristics.
    11·1 answer
  • Describing Editing Task
    6·1 answer
  • Why do computers use zeros and ones? a. because combinations of zeros and ones can represent any numbers and characters b. becau
    6·1 answer
  • 7x+ 2x = 14<br>want is (x)?​
    15·1 answer
  • BrainPower Tutoring The owner of BrainPower Tutoring needs an application to calculate and print estimates to provide to potenti
    14·1 answer
  • A computer scientist creates an app that tells you a funny joke each time you touch the Joke button.
    15·1 answer
  • N
    10·1 answer
  • What is the computer?​
    9·1 answer
  • Https://forms.gle/eP8F5eKC2AUaCsB67
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!