Question: #include int main(){ int i, n; double sum = 0.0, sum1 = 0.0, max, min ,number; char answer; printf( Do you know how many stocks
#include
int i, n; double sum = 0.0, sum1 = 0.0, max, min ,number; char answer;
printf(" Do you know how many stocks you would like to put in? Enter y or n: "); scanf(" %c",&answer); if (answer == 'y'){ printf("Enter the number of stocks you liked to be analzyed: "); scanf("%d",&n); for(i = 0;i if(max < number) max = number; if(min > number) min = number; } } if(n>0) printf("Average price is: $%.2f ",sum/n); else printf("Average price is 0 "); double variance = sum1/n - (sum/n)*(sum/n); printf("Variance is: $%.2f ",variance); printf("The highest price is: $%.2f ",max); printf("The lowest price is: $%.2f ",min); } } this is my code so far without using negative number will termninate program but will caculate the values that was entered. so if the user enters stock 1:20.00 stock2:30.00 stock3:50.00 stock4:-50.00 terminate program these are the mean, variance, min and max of what you entered
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
