answersLogoWhite

0


Best Answer

Assuming the image is an RGB image, sum the red, green and blue components of the pixels separately then divide each by the number of pixels. E.g., given two pixels RGB(a, b, c) and RGB(x, y, z) the mean is RGB ((a+x)/2, (b+y)/2, (c+z)/2).

User Avatar

Wiki User

7y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

10y ago

#include

#include

#include

#include

using namespace std;

int input_number( unsigned index )

{

string input = "", nth = "";

int number = 0;

switch(index%10)

{

case(1): nth="st"; break;

case(2): nth="nd"; break;

case(3): nth="rd"; break;

default: nth="th";

}

while( true )

{

cout<<"Please enter the "<

getline( cin, input );

stringstream ss( input );

if( ss >> number )

break;

cout<<"Invalid number, please try again"<

}

return( number );

}

int main()

{

unsigned index=0, max_numbers=50;

int mean=0, sd=0;

__int64 sum=0;

vector number;

cout<<"Enter "<

while( index

number.push_back( input_number( ++index ));

cout<<"\nSet of numbers: ";

for(index=0; index

{

sum += number[index];

cout<

}

cout<<'\n'<

mean = sum / number.size();

for(index=0; index

sd += (number[index]-mean) * (number[index]-mean);

sd /= number.size();

sd = (int) sqrt((double) sd);

cout<<"Sum: "<

cout<<"Mean: "<

cout<<"SD: "<

cout<

}

Example Output

Enter 50 numbers

Please enter the 1st number: 42

Please enter the 2nd number: 54

Please enter the 3rd number: 62

Please enter the 4th number: 89

Please enter the 5th number: 87

Please enter the 6th number: 95

Please enter the 7th number: 12

Please enter the 8th number: 15

Please enter the 9th number: 65

Please enter the 10th number: 984

Please enter the 11st number: 123

Please enter the 12nd number: 84

Please enter the 13rd number: 6

Please enter the 14th number: 65

Please enter the 15th number: 54651

Please enter the 16th number: 65

Please enter the 17th number: 9

Please enter the 18th number: 9

Please enter the 19th number: 9898

Please enter the 20th number: 454

Please enter the 21st number: 21

Please enter the 22nd number: 56

Please enter the 23rd number: 5665

Please enter the 24th number: 45

Please enter the 25th number: 7

Please enter the 26th number: 54

Please enter the 27th number: 25

Please enter the 28th number: 7

Please enter the 29th number: 6782

Please enter the 30th number: 981

Please enter the 31st number: 6514

Please enter the 32nd number: 213654

Please enter the 33rd number: 45

Please enter the 34th number: 984

Please enter the 35th number: 564

Please enter the 36th number: 1

Please enter the 37th number: 6

Please enter the 38th number: 4654

Please enter the 39th number: 49

Please enter the 40th number: 61

Please enter the 41st number: 321

Please enter the 42nd number: 951

Please enter the 43rd number: 324

Please enter the 44th number: 8

Please enter the 45th number: 98

Please enter the 46th number: 951

Please enter the 47th number: 65

Please enter the 48th number: 65

Please enter the 49th number: 54

Please enter the 50th number: 6

Set of numbers: 42 54 62 89 87 95 12 15 65 984 123 84 6 65 54651 65 9 9 9898 454 21 56 5665 45 7 54 25 7 6782 981 6514 213654 45 984 564 1 6 4654 49 61 321 951 324 8 98 951 65 65 54 6

Sum: 309887

Mean: 6197

SD: 8955

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

to calculate standard deviation using pointers

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write a c plus plus program that computes the sum mean and standard deviation of 50 numbers?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is block programming?

it is a program that computes whit aerodynamic serious consequences with full winded service that control a component


How many days after a program deviation occurs should a program manager inform the milestone decision authority?

90


How do you write a c program that computes results of 10 students for any given 4 subjects grading their results from a A to U?

ghfj


Program for marksheet in c language?

The std::cout and std::cin streams are peculiar to the C++ standard library. They are not available in the C standard library, but are analogous to stdin and stdout which is in the C standard library.


How do you write a CPP program to find standard deviation of N numbers?

1. Calculate the mean average of the N numbers. Suppose it is stored in the variable D. 2. Now calculate the differences between each number with D and square the value. As there are N numbers so store this difference in an array. Example arr[0] = (num0 - D)^2; arr[1] = (num1 - D)^2; arr[N-1] = (numN - D)^2; 3. Now sum array value and divide by N, suppose the value is stored in F. Now square root F. It is the standard deviation of your N number. I hope you can write the code by yourself or follow the part: suppose you will store the N numbers in an array num. Now: int num[N+2], D = 0; //or declare the num array as float or double if there are any precision value for(int i = 0; i &lt; N; i++) { D += num[i]; } D /= N; int arr[N+2]; for(int i = 0; i &lt; N; i++) { arr[i] = (num[i] - D)^2; //square the difference. } int F = 0; //if precision value is accepted then declare F as float or double not int. for(int i = 0; i &lt; N; i++) { F += arr[i]; } F /= N; F = sqrt(F); //use #include &lt;cmath&gt; in your header file list so that you can use sqrt() function or simply use #include &lt;bits/stdc++.h&gt; cout&lt;&lt;F&lt;&lt;endl; - Thanks

Related questions

How do you calcuate standard deviation?

A worked out example is shown in the related link. There are a number of calculators that do this automatically. Also, the Excel program (and most other spreadsheet programs) include a standard deviation function. In Excel, it is +stdev(a1:a10) for a list of numbers from a1 to a10.


What is block programming?

it is a program that computes whit aerodynamic serious consequences with full winded service that control a component


How many days after a program deviation occurs should a program manager inform the milestone decision authority?

90


How do you write a c program that computes results of 10 students for any given 4 subjects grading their results from a A to U?

ghfj


How do you write a c program to calculate mean variance and standard deviation?

Program in CHere is a program in C to calculate mean variance and standard deviation: #include#includevoid main(){float a[50],sum=0,vsum=0,mean,variance,sd;int n,i;printf("Enter the no of valus");scanf("%d",&n);printf("Enter the no of valus");for(i=0;i


What is the verb for computer?

The verb for computer is compute.Other verbs are computes, computing and computed."I am computing"."We have computed the program""I like to compute".


Write a program in C programming language that computes the roots of the quadratic equation ax2 plus bx plus c?

Write your program and if you are having a problem post it here with a description of the problem you are having. What you are asking is for someone to do your homework for you.


Why important to have standard text code?

standard text code is important because it would enable any programmer or programme to use the same combination of numbers to represent the same individual pieces of data.


How do you write a standard basic program?

That really depends on what sort of program you are trying to build, what do you want the program to do?


Implement a short C program that works with factorization of integers you will write C program that computes and prints out the sum of all natural numbers below 100000 that are multiples of 3or 5 or7?

#include&lt;stdio.h&gt; #include&lt;conio.h&gt; void main() { int i=1,sum=0; clrscr(); while(i&lt;10000) { if((i%3==0)(i%5==0)(i%7==0)) { sum=sum+i; } i++; } printf("\nThe sum is%d",sum); getch(); }


Program to count the number of numbers in an array using 8085 microprocessor?

A program which is used to count the number of numbers in an array using a 8085 microprocessor is known as a assembly language program.


What is the AFOSH standard for radio frequency radiation safety program?

AFOSH Standard 48-9