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
VikaD [51]
2 years ago
8

Write a program whose inputs are two integers, and whose output is the smallest of the two values.

Computers and Technology
1 answer:
andrezito [222]2 years ago
8 0

Method 1 :

Using If else statements: If the condition checks whether num1 is smaller than num2 if so it will print 'Smallest of these two integers is num1'.

else it will print 'Smallest of these two integers is num2'

Method 2:

Using the 'min' method: using the method min(num1,num2), the program finds the smallest value and prints it directly to the user.

Python Program using method 1

#PYTHON PROGRAM TO FIND SMALLEST INTEGER VALUE FROM TWO INPUTS FROM USER - Method 1

#Accepts inputs from user

num1 = int (input ("Enter your first number:")) #Gets the first integer input from user and stores in num1

num2 = int (input ("Enter your second number: ")) #Gets the second integer input from user and stores in num2

#Finding output by if else

#Checks num1 smaller than num2

if (num1 < num2):

#assign num1 to small

small = num1

else:

#assign num2 to small

small = num2

 

print ("Smallest of these two integers is", small)

Python Program using method 2

#PYTHON PROGRAM TO FIND SMALLEST INTEGER VALUE FROM TWO INPUTS FROM USER - Method 2

#Accepts inputs from user

num1 = int (input ("Enter your first number:")) #Gets the first integer input from user and stores in num1

num2 = int (input ("Enter your second number: ")) #Gets the second integer input from user and stores in num2

#Finding output using min method

print("\n Smallest of these two integers is",min(num1,num2)) #Prints output to user

You might be interested in
Two Smallest (20 points). Write a program TwoSmallest.java that takes a set of double command-line arguments and prints the smal
Ivan

Answer:

Written in Java

import java.util.*;

public class Main {

   public static void main(String args[]) {

     int n;

     Scanner input = new Scanner(System.in);

     n = input.nextInt();

     double nums []= new double [n];

     for (int i=0; i<n;i++)

     {

         nums[i] = input.nextDouble();

     }

     

     Arrays.sort(nums);

     System.out.println("The two smallest are: ");

     for (int i=0; i<2;i++)

     {

         System.out.println(nums[i]);

     }

   }

}

Explanation:

This line declares number of input

     int n;

This line calls the Scanner function

     Scanner input = new Scanner(System.in);

This line gets input from user

     n = input.nextInt();

This line declares an array of n elements

     double nums []= new double [n];

The following iteration gets input into the array

     for (int i=0; i<n;i++)

     {

         nums[i] = input.nextDouble();

     }

This line sorts the array

     Arrays.sort(nums);

The following iteration prints the two smallest

     System.out.println("The two smallest are: ");

     for (int i=0; i<2;i++)

     {

         System.out.println(nums[i]);

     }

4 0
3 years ago
You approach a railroad crossing with a cross buck sign that has no light or gates . What should you do ?
Sergio039 [100]
You should probably slow down, make sure no trains are coming (and listen for any train sounds!) before proceeding to cross and go about your way :)
6 0
4 years ago
What are the main dimensions of information systems
anastassius [24]

\huge\mathcal\colorbox{yellow}{{\color{blue}{AnSwEr~↓~↓~}}}

There are three dimensions of information systems

  • organizational
  • management
  • technology.

\huge \colorbox{blue}{hope \: it \: help \: u}

8 0
3 years ago
What does “default” refer to? the ability to be used as, or directly converted to, cash. the failure to pay back a loan. the amo
Vaselesa [24]
The answer is "the failure to pay back a loan".

In computer systems, we have a different meaning to the word default. It is referred to the setting or option in a computer upon opening a program or application. But according to the dictionary, default refers to the failure to make a payment such as a loan.
8 0
3 years ago
Conceptual note-taking is the act of writing down information in the order it is given. drawing attention to details with a mark
Dvinal [7]

Answer:A

Explanation:Conceptual notetaking is the act of writing down information in the order it is given.

4 0
3 years ago
Read 2 more answers
Other questions:
  • The _____ element of the wsdl describes the data being exchanged between the web service providers and the consumers, including
    12·1 answer
  • The World Wide Web (not the Internet) went live in this decade:
    8·2 answers
  • Write a program that prompts the user to enter the number of integer numbers you need to enter, then ask user to enter these int
    5·1 answer
  • Partitioning the hard drive allows you to do which of the following?
    11·1 answer
  • Examine the following declarations and definitions for the array-based implementations for the Stack and Queue ADTs. Assume that
    14·1 answer
  • What is one advantage of top-down programming design?
    8·1 answer
  • Write a flowchart and program that does the following: Asks the user for the average temperature in each of the last 12 months A
    12·1 answer
  • When your grounded and the only thing you can get on is a computer........................oh welllllllllllllllllllllllllllllllll
    7·1 answer
  • Write any two web browers​
    10·1 answer
  • Formulas should follow the___
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!