Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

how to write a program with a loop that lets the user enter a series of integers?

–1 vote
asked Oct 30, 2019 by Destiny
The user should enter -99 to signal the end of the series. After all the numbers have been entered, the program should display the largest and smallest numbers entered.

2 Answers

0 votes
answered Nov 3, 2019 by joshua43433
n=int(input("enter element limit:"))

num=[ ]

G=""

L=""

for i in range(n):

    N=int(input("enter numbers:"))

    num.append(x)

print(N)

for j in range(n):

    if num[0]<num[ j ]:

        num[j]=L

    if num[0]>num[j]:

       num[j]=G

print(L,G)
commented Nov 4, 2019 by DSG
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main
{
    public static void main(String[] args) {
        System.out.println("ENter number(enter -99 to exit):");
        ArrayList<Integer> arr = new ArrayList <>();
        int input = 0;
       
        try (Scanner sc = new Scanner(System.in)){
            while(sc.hasNext()) {
                input = sc.nextInt();
                
                if(input == -99) {
                    break;
                }
                arr.add(input);
            }
        } catch(Exception e){
            System.out.println(e);
        }
        Collections.sort(arr);
        //System.out.println(arr);
        System.out.println("Lowest element:"+arr.get(0));
        System.out.println("Highest element:"+arr.get(arr.size()-1));
    }
}
0 votes
answered Nov 6, 2019 by anonymous

#include <bits/stdc++.h>

using namespace std;

int main() {
    int mini=INT_MAX;int maxi=INT_MIN;
    
    int x;
    cin>>x;
    while(x!=-99)
    {
        mini=min(mini,x);
        maxi=max(maxi,x);
        cin>>x;
    }
    cout<<mini<<" "<<maxi<<"\n";
    
}

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...