Question

1.(40) Write a program that will find the smallest value entered by the user and print out the entered numbers with the smallest value subtracted. The program is to ask for the number of points and then read in that many points.

C++ program please.

As simple as possible.

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

================code===========================
#include<iostream>
using namespace std;
int main ()
{
int a[100];
int f[100];
int min,b=0,c,n;
cout<<"\nEnter the total number of points:";
cin>>n;
while (b<n)
{
cout<<"Enter point number "<<b<<" : ";
cin>>c;
a[b]=c;
f[b]=c;
b=b+1;
}
b=0;
min=a[b]; //assuming 1st element is the minimum
while (b<n)
{
if (a[b]<=min)
{
min=a[b];
}
b=b+1;
}
cout<<"\nSmallest number is : "<<min;
cout<<"The numbers after subtraction are:"<<endl;
for(int i=0;i<n;i++)
{
cout<<f[i]- min<<endl;
  
}
//getche();
return 0;
}

==========OUTPUT===============

options compilation execution Enter the total number of points:5 Enter point number 0 12 Enter point number 1 10 Enter point

Add a comment
Know the answer?
Add Answer to:
C++ program please. As simple as possible. 1.(40) Write a program that will find the smallest...
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
  • 3. (c-program) Write a program that finds the largest and smallest value in a series of...

    3. (c-program) Write a program that finds the largest and smallest value in a series of numbers entered by a user. The user must enter 25 values. Note if that if the user enters "0" they must correct and add another number. Print out the original entered values, the largest number, the smallest number. Note whether the user tried to enter "O".

  • 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...

  • This program is in C++ Write a program that validates charge account numbers read in from...

    This program is in C++ Write a program that validates charge account numbers read in from the file Charges.txt following this assignment (A23 Data). Use a selection sort function on the array to sort the numbers then use a binary search to validate the account numbers. Print out the sorted list of account numbers so you can see the valid ones. Prompt the user to enter an account number and the validate that number. If the account number entered is...

  • Write a program called SmallestLargest.java which outputs the biggest and smallest numbers in a list of...

    Write a program called SmallestLargest.java which outputs the biggest and smallest numbers in a list of numbers entered by the user. Ask the user for a terminating value which should be entered again when they are done inputting the list of numbers. First output the biggest number and then the smallest number. There must be at least 1 number in the list. YOU MUST USE THE IO MODULE FOR INPUT/OUTPUT. Report bad input via IO.reportBadInput() and exit on error. Example:...

  • (C programing, Not C++) Write a program in C that asks the user to input 10...

    (C programing, Not C++) Write a program in C that asks the user to input 10 numbers. Store these numbers in an array. Then ask the user to input a single number. Your program should execute a linear search on the array, trying to find that number. If the number exists in the array, have the program print out which position/element the number was found at. If the target number is not in the array, have the program print out...

  • 1- Write a program to read 10 numbers and find the average of these numbers. Use...

    1- Write a program to read 10 numbers and find the average of these numbers. Use a while loop to read these numbers and keep track of input numbers read. Terminate the while loop with a sentinel value. 2- Now modify the program to find the maximum of these numbers as well. The program should print the number of elements read as input and run until -1 is entered. (-1 is the sentinel that terminates the loop and the program)...

  • In C++ 2. Write a program that allows the user to enter a series of positive...

    In C++ 2. Write a program that allows the user to enter a series of positive numbers between 1 and 100 and displays the smallest and largest of the numbers entered. The program should not store the numbers that were entered, only keep track of the smallest and largest ones. The program should continue accepting numbers until the value 0 is entered and then display the results. If a number out of range is entered, tell the user it is...

  • •Write a java program to read 10 numbers and print them in reverse order. Modify your...

    •Write a java program to read 10 numbers and print them in reverse order. Modify your program to work for N numbers given by the user Extend your program to find the average of these numbers Extend your program to find the smallest number of these numbers Extend your program to find the largest number of these numbers •Write a program to read 10 numbers and print them in reverse order. Modify your program to work for N numbers given...

  • Write a java program making use of methods that finds the smallest of any three numbers...

    Write a java program making use of methods that finds the smallest of any three numbers that the user inputs. You must use JoptionPane to input the three numbers. A first method must be called and used to develop logic to find the smallest of the three numbers. A second method must be used to print out that smallest number found.

  • MATLAB ONLY PLEASE...ALSO AS SIMPLE AS POSSIBLE...NEW TO LANGUAGE Write a code that will ask the...

    MATLAB ONLY PLEASE...ALSO AS SIMPLE AS POSSIBLE...NEW TO LANGUAGE Write a code that will ask the user to input a positive number x. If the number is negative the program will keep asking again and again (as long as the value is negative) until the user inputs a positive value. At the end of the program, calculate the following: y = e-x

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