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
lubasha [3.4K]
3 years ago
13

Given the int variables x, y, and z, write a fragment of code that assigns the smallest of x, y, and z to another int variable m

in. Assume that all the variables have already been declared and that x, y, and z have been assigned values.
Computers and Technology
1 answer:
Marysya12 [62]3 years ago
6 0

Answer:

// here is code in C++.

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

   // variables

   int x=5,y=2,z=9;

   int min;

   // find the smallest value and assign to min

   // if x is smallest

   if(x < y && x < z)

   // assign x to min

    min=x;

     // if y is smallest

else if(y < z)

 // assign y to min

    min=y;

// if z is smallest

else

 // assign z to min

    min=z;

// print the smallest

cout<<"smallest value is:"<<min<<endl;

return 0;

}

Explanation:

Declare and initialize variables x=5,y=2 and z=9.Then check if x is less than y and x is less than z, assign value of x to variable "min" .Else if value of y is less than value of z then smallest value is y, assign value of y to "min".Else z will be the smallest value, assign its value to "min".

Output:

smallest value is:2

You might be interested in
Identify the tasks that people can perform using a web browser. View a web page Program a computer Record a video Organize the e
padilas [110]

Answer:

1,3,5,6,7,8 on edge2020

Explanation:

7 0
3 years ago
Read 2 more answers
Which of the following represent correct syntax to display first name from global variable user? Select the one correct answer.
Zielflug [23.3K]

Answer:

Option D i.e., {!$User.FirstName} is the correct answer.

Explanation:

The following option is correct because in the following statement, the user programmer will ask to display the first name by using the global variable then, in the PHP Programming Language the following is the correct way to display the first name of the user, which is inside the curly braces then, not operator and then, name of the variable through which it call.

6 0
4 years ago
How to remove special formatting from a table in word.
ch4aika [34]

Answer:

Clear Format

Explanation:

7 0
2 years ago
Each of the parts a. through c. below is preceded by a comment indicating what the code should do. There is a least one problem
Svetach [21]

Answer:

The correction is as follows:

(a)

small = arr[0];

for (int j = 0; j < arr.length; j++){

if (small > arr[j]) {

small = arr[j];      }  }

(b)

double sum = 0;

int n = arr.length;

for (int k = arr.length-1; k >= 0; k--)

sum = sum + arr[k];  

double avg = sum /n;

(c)

int[] a = {1,2,3,4,5};

int[] b = new int[5];

for (int i=0; i<a.length; i++)

b[i] = a[a.length-i-1];

Explanation:

Required

Correct each of the given code

a.

This line is correct; it initializes the smallest to the first element

small = arr[0];

This iterates through the array; however, the last element is left out.

for (int j = 0; j < arr.length-1; j++)

So, the correct code is: <em>for (int j = 0; j < arr.length; j++){</em>

The expected remaining part of the program which compares the elements of the array is missing

I've completed the code [See the answer section]

b.

By syntax this line is correct. However, for the average to be calculated as double; sum has to be declared as double

int sum = 0;

So, the correct code is: <em>double sum = 0; </em>

This line correctly calculates the length of the array

int n = arr.length;

This iteration will create an endless loop

for (int k = arr.length; k <= 0; k--)

So, the correct code is: <em>for (int k = arr.length-1; k >= 0; k--) </em>

This correctly add up the elements of the array

sum = sum + arr[k];

This correctly calculate the average of the array elements

double avg = sum /n;

(c)

The array a is incorrectly initialized because there is no matching end curly brace

int[] a = {1,2,3,4,5);

So, the correct code is: <em>int[] a = {1,2,3,4,5};</em>

This correctly create array b with 5 elements

int[] b = new int[5];

This iterates through a; however, the last element is left out

for (int i=0; i<=a.length; i++)

So, the correct code is: <em>for (int i=0; i<a.length; i++)</em>

This will create an out of bound error

b[i-1] = a[a.length-i];

So, the correct code is: <em>b[i] = a[a.length-i-1];</em>

5 0
3 years ago
The following code processes a file containing five positive numbers. What will the variable $result contain after the code is e
jolli1 [7]

Answer:

highest of five numbers in the file

Explanation:

  • This code reads the file "some-file.txt" and saves the result in variable "somefile"
  • The runs a for loop for a count of 5.
  • In each loop it compares the current value of the file with the value of the variable result and if the result is true it updates the value of the variable result.
  • At the end of this code the variable result will contain the highest value in the file "some-file.txt" and print it.

6 0
4 years ago
Other questions:
  • Jamal is a graphic designer.a. What hardware tool would you suggest for his computing system? Include an explanation and the cos
    8·1 answer
  • Larry finds it easy to run legacy programs and applications in a virtualized environment. how does the virtualization provider m
    7·2 answers
  • A process is: An activity of a function that is performed for some specific business reason A single piece of data within a syst
    14·1 answer
  • Hat is the purpose of the domain name?
    7·2 answers
  • What word describes a violation of copyright laws? What rights do copyright holders have over their work of art
    5·2 answers
  • A print server uses a print ________ as a software holding area for jobs waiting to be printed.
    5·2 answers
  • What are the 7 c' to communication​
    14·2 answers
  • Which step do you think is most useful from big data life cycle and why?
    12·1 answer
  • Explain how you would set up a Demilitarized Zone on. You have 25 workstations and a server on your site. Explain what additiona
    5·1 answer
  • You have the following code:
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!