Question

2. Write an algorithm to display up to 10 user inputs 3. Write an algorithm to display print first 5 items in a collection. 4

Help pls for assignment

0 0
Add a comment Improve this question Transcribed image text
Answer #1

2)

->initialize array of size 10 and i to n0

->Iterate loop 10 times

->read input from user and store it in array

->increment i value

3)

->Iniitialize i to 0

->Iterate array 5 times.

->display element in that index i

->Increment i value

4)

->read 3 numbers a,b,c

->check if a>b and a>c

->display a is large number

->else check b>c

->display b is large number.

->else

->c is the largest number.

CODE:

#include<iostream>
using namespace std;
int main()
{
   int arr[10],i,j;
   for(i=0;i<10;i++) {
       cin>>arr[i];
   }
  
   //3)ans
   for(i=0;i<5;i++) {
       cout<<arr[i]<<"\t";
   }
   //4)ans..
   int a,b,c;
   cout<<"\nEnter 3 numbers : ";
   cin>>a>>b>>c;
   if(a>b && a>c)
       cout<<a<<"is large";
   else if(b>c)
       cout<<b<<" is large";
   else
       cout<<c<<" is large";
  
}

OUTPUT:

Dev-C++ 5.2.0.2 Eile Edit Search View Project Execute Debug Tools CVS Window Help IO. * B65E 10HIIH+* ] 0 (globals) algo.cpp

if you have any doubts please COMMENT...

if you understand the answer please give THUMBS UP...

Add a comment
Know the answer?
Add Answer to:
Help pls for assignment 2. Write an algorithm to display up to 10 user inputs 3....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a script which asks the user to input numbers until the user inputs 0. Then...

    Write a script which asks the user to input numbers until the user inputs 0. Then the script should print only the positive numbers entered by the user, in reverse order E.G. if the user inputs '4, -1, 5, 2, -3, -8, 0', the script should print '2, 5, 4'. Please don't copy someone else's answer as they don't work.

  • Write an algorithm that takes an array B and a number N as inputs. Suppose that...

    Write an algorithm that takes an array B and a number N as inputs. Suppose that the array B contains n distinct numbers. Compute the sum of the N largest numbers in the array B. Example: if the array B= [4, 5, 8, 11, 3] and N = 3, then the algorithm should return 24 (11+8+5).

  • 2. Write an application that inputs a 3-digits number from the user and checks if all...

    2. Write an application that inputs a 3-digits number from the user and checks if all digits are prime numbers. If all digits are prime your program should stop. Use do/while for reading the input and any loop format to test if the number is prime. When checking the prime numbers don't use an if to check numbers from 1 - 9; you need to find an algorithm to check if the number is prime or not. Enter a 3-digit...

  • In Matlab, write a script which asks a user to input numbers until the user inputs...

    In Matlab, write a script which asks a user to input numbers until the user inputs 0. Then the script should print only the positive numbers entered by the user, in reverse order. For example, if the user inputs “4,-1,5,2,-3,-8,0” the script should print “2,5,4”.

  • Write a single program in java using only do/while loops for counters(do not use array pls)...

    Write a single program in java using only do/while loops for counters(do not use array pls) for the majority of the program and that asks a user to enter a integer and also asks if you have any more input (yes or no) after each input if yes cycle again, if not the program must do all the following 4 things at the end of the program once the user is finished inputting all inputs... a.The smallest and largest of...

  • 5.2 Write a program that repeatedly prompts a user for integer numbers until the user enters...

    5.2 Write a program that repeatedly prompts a user for integer numbers until the user enters 'done'. Once 'done' is entered, print out the largest and smallest of the numbers. If the user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the number. Enter 7, 2, bob, 10, and 4 and match the output below. ​ 1 largest = None 2 smallest = None 3 while True: 4...

  • # Write PYTHON programs that read a sequence of integer inputs and print # a.  The...

    # Write PYTHON programs that read a sequence of integer inputs and print # a.  The smallest and largest of the inputs. # b.  The number of even and odd inputs. # c.  Cumulative totals. For example, if the input is 1 7 2 9, the program should print # 1 8 10 19. # d.  All adjacent duplicates. For example, if the input is 1 3 3 4 5 5 6 6 6 2, the # program should print...

  • In Python 3, Write a program that reads a set of floating-point values. Ask the user...

    In Python 3, Write a program that reads a set of floating-point values. Ask the user to enter the values, then print: The number of values entered. The smallest of the values The largest of the values. The average of the values. The range, that is the difference between the smallest and largest values. If no values were entered, the program should display “No values were entered” The program execution should look like (note: the bold values are sample user...

  • :Pls help for this programing problem in c++ (standard IO without file read/write),better with some comment...

    :Pls help for this programing problem in c++ (standard IO without file read/write),better with some comment about why coding that way,thanks Problem A: Counting Numbers Problem Description Write a program that reads numbers from the keyboard into an integer array. You may assume that there will be 50 or fewer entries in the array. Your program allows any number of numbers to be entered, up to 50 numbers. The output is to be a two-column list. The first column is...

  • pls help Write a method void remove(int *a, int index) that will remove the number at...

    pls help Write a method void remove(int *a, int index) that will remove the number at the given index and shift all remaining numbers one position to the left in the array a. Assume 1that the last element of the array is -1. Now, write a main function that will define an array int A[40]=[3, 5, 9, 17, 24, -1]; read from user input an index; and call the method remove passing array A and the index given by the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT