Program:
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
float num,sum=0.0,average,sd=0.0;
float arr[100];
int count=0;
for(int i=0;i<=99;i++)
{
cout<<"Enter a real number: ";
cin>>num;
if(num>1.0e9) // 1.0e9 = 1000000000
{
break;
}
arr[i]=num;
sum=sum+num;
count++;
}
average=sum/count; //to get average
int zero=0;
float min=arr[0];
float max=arr[0];
for(int i=0;i<count;i++)
{
sd=sd+pow(arr[i]-average,2);//code for standard Deviation but
without square root
if(min>arr[i]) //code for Minimum Value
{
min=arr[i];
}
if(max<arr[i]) //code for maximum value
{
max=arr[i];
}
if(arr[i]==0) // code for occurences of zero
{
zero++;
}
}
float range=(max-min)/2; // to get range
cout<<"\nAverage: "<<average<<endl;
cout<<"Standard Deviation:
"<<sqrt(sd/count)<<endl; //to get Standard
Deviation
cout<<"Minimum Value: "<<min<<endl;
cout<<"Maximum value: "<<max<<endl;
cout<<"Range: "<<range<<endl;
cout<<"The number of times zero is input:
"<<zero<<endl;
return 0;
}
Write a program that inputs up to 100 real numbers from the keyboard (one at a...
using C++ Write a program that: a) Inputs an integer n from the keyboard where n<=100. If n is out of range then print out an error message and ask for another input. This process repeats until a valid value for n is obtained. b) Inputs two 1D arrays of doubles A and B (of size n) from the keyboard. c) Inputs an integer k (from 1 to 3) from the keyboard. d) If k = 1 then it calculates...
Write a program in c++ that generates a 100 random numbers between 1 and 1000 and writes them to a data file called "randNum.dat". Then re-open the file, read the 100 numbers, print them to the screen, and find and print the minimum and maximum values. Specifications: If your output or input file fails to open correctly, print an error message that either states: Output file failed to open Input file failed to open depending on whether the output or...
6. Consider a C program that reads two real numbers from the keyboard followed by a character where the character can be one of the operators +,-, *, 1, or % providing the addition, subtraction, multiplication, division, or remainder respectively. Then the result is displayed on the screen For example, if the user types 2.0 3.0 % then your code will display: Note: In the above example the inputs are real numbers but the remainder only performs an integer operation....
Write a ( JAVÅ) program which reads (from the keyboard) numbers (doubles) until a zero is input and computes the maximum and minimum of all the read numbers (excluding the terminating zero). Note: you must allow for negative as well as positive numbers. Hint: look at java.lang.Double.MAX_VALUE and java.lang.Double.MIN_VALUE.
Write a Java program that inputs a list of integer values in the range of − 1 to 100 from the keyboard and computes the sum of the squares of the input values. This program must use exception handling to ensure that the input values are in range and are legal integers, to handle the error of the sum of the squares becoming larger than a standard Integer variable can store, and to detect end-of-file and use it to cause...
Write a C PROGRAM that will read in 10 floating-point numbers from the keyboard and load them into an array. Add up all the values and store the answer in a variable. Find the largest and smallest number in the array. Put each into its own variable. Print to the screen the sum, largest value, and smallest value. Copy the array to a second array in reverse order. Print out the second array. Read in 20 integer numbers, all in...
Design a program that inputs a list of up to 50 real values from a data file, Problem1InputFile.txt, and print the count and smallest value to the screen. Hint: an array is not really needed, but you can use one. Here is one sample input file for Problem1InputFile.txt (note that there is one real value per line and there is an extra blank line at the end): 10.5 2.1 2.0 -1.7 -0.5 Sample output: Count: 5 Smallest: -1.7 Give pseudocode...
Write a C program using array(s) that inputs 20 real numbers, then displays it backward on the screen. Print the given array and backward array.
1. Write a program that reads a sequence of numbers from the keyboard, and displays the smallest number. The sequence has at least one number and is terminated by -999(-999 will not appear in the sequence other than as the end marker). 2. Write a program which requests an integer input n from the keyboard and computes the sum of square of k for all k from 1 to n(inclusive). use java
Write a MARIE assembly program to read two different positive numbers from the keyboard and output the smaller number to the screen.