Question

In: Computer Science

Read three integers from user input.

Read three integers from user input.

Solutions

Expert Solution

Reading integers from user input in different languages are different. Here I'm giving you how you can read three integers from user input and display the entered integers in C and C++:

1.C

#include <stdio.h>

int main() {
    int a,b,c; //3 integers to store value
    printf("Enter 3 integers: "); //printing message to enter integers
    scanf("%d %d %d",&a,&b,&c);  //reading integers
    
    printf("The integers are : \ta = %d \tb = %d \tc = %d",a,b,c); //printing a,b,c
    return 0;
}

OUTPUT:

2.C++

#include <iostream>

int main() {
    
    int a,b,c; //3 integers to store value
    std::cout<<"Enter 3 integers: "; //printing message to enter integers
    std::cin>>a>>b>>c;  //reading integers
    
    std::cout<<"\nThe integers are : \ta ="<<a<<"\tb ="<<b<<"\tc ="<<c; //printing a,b,c

    return 0;
}

OUTPUT:


Related Solutions

Read in user-input integers one at a time until the user types ‘q’, storing all inputs...
Read in user-input integers one at a time until the user types ‘q’, storing all inputs in a list. Then, print out the even numbers in increasing order, from smallest value to largest. Python
The user will input a dollar amount as a floating point number; read it from input...
The user will input a dollar amount as a floating point number; read it from input using a Scanner and the .nextDouble() method. Convert the number of dollars into a number of whole (integer) cents, e.g., $1.29 = 129 cents. Determine and output the optimal number of quarters, dimes, nickels, and pennies used to make that number of cents. Ex: if the input is 1.18 The output should be 4 1 1 3 for 4 quarters, 1 dime, 1 nickel,...
Write a program that read the input from user and convert it to binary and hex...
Write a program that read the input from user and convert it to binary and hex in C language.
1. Read a line of input from the user (as a string) and find out if...
1. Read a line of input from the user (as a string) and find out if there are any vowels in the string. Use a break or continue keyword (whichever is appropriate) to notify that a vowel has been found. Prompt for another string and search again until the user enters 'exit' into the program. 2. Ask the user how many random numbers they would like to see. Ask the user to provide the lowest number they would like to...
Write MIPs program that will read two integers from the user and compute for the sum...
Write MIPs program that will read two integers from the user and compute for the sum and difference of the two integers. Ask the user whether he wants to repeat the program : "[Y/y] / [N/n] ?".
Write a program that uses a while statement to read integers from the user and prints...
Write a program that uses a while statement to read integers from the user and prints the sum, average, and largest of these numbers. The input should terminate if the user enters 999. The average should be output with 4 digits of precision. c++ please ASAP
Write a program that uses a loop to read 10 integers from the user. Each integer...
Write a program that uses a loop to read 10 integers from the user. Each integer will be in the range from -100 to 100. After all 10 integers have been read, output the largest and smallest values that were entered, each on its own line in that order. Avoiding using the max or min functions from Python, and definitely use a loop to read the integers instead of 10 input statements.
Write a program that will read user input, and do the following: 1. The user can...
Write a program that will read user input, and do the following: 1. The user can input letters [A-Z] as much as he wants (ignore case). 2. If the user input other than letters or two characters, stop the input process and start to print unduplicated sorted pairs such as the below examples: User input: A a e b d d D E a B 1 Output: AB AD AE BD BE DE User Input: a q w e dd...
Write a program, ArrayRange, that asks the user to input integers and that displays the difference...
Write a program, ArrayRange, that asks the user to input integers and that displays the difference between the largest and the smallest. You should ask the user the number of integers s/he would like to enter (this will allow you to set the length of the array). Allow the user to input all the numbers and then store them in the array. Search the array for the largest number, then search for the smallest, and finally compute the calculation. Display...
Create a program that asks the user for two positive integers. If the user's input for...
Create a program that asks the user for two positive integers. If the user's input for either integer is not positive (less than or equal to 0), re-prompt the user until a positive integer is input. You may assume that all inputs will be integers. Print out a list, ascending from 1, of all divisors common to both integers. Then, print out a message stating whether or not the numbers are "relatively prime" numbers. Two positive integers are considered relatively...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT