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
The function below takes one parameter: a list of numbers (num_list). Complete the function to return a new list containing only
agasfer [191]

Answer:

Following are the program in the Python Programming language.

#define function

def negative_num(num_list):

 #set list type variable

 nlist=[]

 #set the for loop

 for n in num_list:

   #check negative numbers

   if(n<0):

     #add the value of n in list

     nlist.append(n)

 #return list

 return nlist

#set new list type variable that store list

newl=[-5,8,-6,3,-4,9,-7]

#print and call the function

print(negative_num(newl))

<u>Output</u>:

[-5, -6, -4, -7]

Explanation:

Here, we define the function "negative_num" and pass an argument "num_list" in its parameter and inside the function.

  • Set new list data type variable "nlist".
  • Set the for loop which iterate as the list.
  • Set the if conditional statement to check the value of the list is less than 0 then, add that negative values in the variable "nlist".
  • Then, return the new list.

Finally, we set a variable "newl" which store the list of negative and positive numbers then, we print and call the function.

6 0
3 years ago
Which description of the plain text file format is most accurate?
dsp73
1. uses binary code to store data!
4 0
3 years ago
Read 2 more answers
Does any one have the computer science 2020 past paper for gcse ocr
valkas [14]

Nope those are quite rare but are found at qdoc.tips

6 0
2 years ago
PLZZZ HELLPP... PhotoShop
Burka [1]
LEFT SIDE :
Layer menu
Layer filters
Layer groups
Link layers

BOTTOM :
Layer effects
Layer menu
Visibility

RIGHT SIDE :
Add new layer
Opacity
Fill opacity

4 0
3 years ago
Write a method maxMagnitude() with two integer input parameters that returns the largest magnitude value. Use the method in a pr
antoniya [11.8K]

Answer:

   public static int maxMagnitude(int a, int b){

       int max;

       if (a>b){

           max = a;

       }

       else{

           max = b;

       }

       return max;

   }

The complete program calling the method is given in the explanation section

Explanation:

import java.util.Scanner;

public class ANot {

   public static void main(String[] args) {

     Scanner in = new Scanner(System.in);

       System.out.println("Please Enter two numbers");

       int num1= in.nextInt();

       int num2 = in.nextInt();

       System.out.println("The largest magnitude number is: "+maxMagnitude(num1,num2));

   }

   public static int maxMagnitude(int a, int b){

       int max;

       if (a>b){

           max = a;

       }

       else{

           max = b;

       }

       return max;

   }

}

The maxMagnitude() method uses if/else statement to compare two ints and return the larger one

7 0
3 years ago
Other questions:
  • This is a free point thing!! I am giving 100 points!! Anyone wanna talk!!!!
    11·2 answers
  • Who invented the Graphical User Interface (GUI)?
    5·1 answer
  • Question 2 of 5
    8·1 answer
  • Which of the following is not regression test case? A. A representative sample of tests that will exercise all software function
    10·1 answer
  • ASAP!!!!****** Need help!!!!
    15·1 answer
  • All 24-point fonts take up the same amount of space on a slide. True False
    7·2 answers
  • What do computer programs generally try to solve and how? A) Computer programs generally try to solve a well-defined problem usi
    14·1 answer
  • Write a program that will remove "May" from the list using .Pop and .Index methods.(5pts) GIVEN: lst=["January", "February", "Ma
    15·1 answer
  • In a school 50% of the students are younger than 10, 1/20 are 10 years old and 1/10 are older than 10 but younger than 12, the r
    7·1 answer
  • The main function of a(n) ____________________ is to centralize access control for the network by keeping an eye on both inbound
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!