473,498 Members | 703 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Showing mean and variance

4 New Member
Hello!

I'm writing a program that calculates and shows the mean and variance of two integers. The result I'm getting is 7. But that's not the mean of 5 and 10 (num1 and num2). What can I do to show both mean and variance together on the screen? What should I put after return to get both mean and variance?

Thank you.

#include <stdio.h>


double statistics (int x, int y){

double mean, var;

mean = (x+y)/2;
var = ((x-mean)*(x-mean) + (y-mean)*(y-mean)) /2;

return mean;
}

int main(){

int num1, num2;

num1 = 10;
num2 = 5;


printf("%lf", statistics(num1, num2));

return 0;
}
Nov 24 '21 #1
2 13461
dev7060
639 Recognized Expert Contributor
I'm writing a program that calculates and shows the mean and variance of two integers. The result I'm getting is 7. But that's not the mean of 5 and 10 (num1 and num2).
Expand|Select|Wrap|Line Numbers
  1. (x+y)/2
produces int type result.

What can I do to show both mean and variance together on the screen? What should I put after return to get both mean and variance?
A function can return one value. Write separate functions or print both from a function.
Dec 1 '21 #2
iamsteve03
1 New Member
int type return, nice one, error-free code
Dec 14 '21 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
4815
by: T.Venkatesh | last post by:
Hi friends, I just got stuck up in JDBC,JSP. My problem is iam unable to display the output of Standard deviation , variance sum, of a column in a JSP page. But it complies- but no display of...
4
6475
by: Matt Larkin | last post by:
I am pulling my hair out trying to solve this one (presumably because I am not particularly trained or skilled at access!) I have a query which summarises the variances that each of my sales...
2
3190
by: chickenyd | last post by:
Hi i am trying to create a program using WML, WMLSCRIPT, AND JSP. The task is to create a website to be displayed in the WAP Browser. In the website for a company called 'BargainBook' that sells...
8
21089
by: SpreadTooThin | last post by:
import array a = array.array('f', ) print a.mean() print a.std_dev() Is there a way to calculate the mean and standard deviation on array data? Do I need to import it into a Numeric Array...
0
2901
by: aboxylica | last post by:
do v have a function to calculate variance, average and standard deviation in python??
3
5008
by: eliasam | last post by:
Hi can anyone help me with this? I've got a field in a query to calculate the weight charge: CalcWeightCharge: * Then in another field i would like to calculate the variance from the given...
4
1512
by: raylopez99 | last post by:
What are these terms in my header anyway? But more importantly for me, look at this code: Lack of variance: why a List<Bananaisn’t a List<Fruit> Many people initially expect the following...
1
1794
by: campechana | last post by:
c sharp code to obtain variance and media.. of n numbers
34
2825
by: ShazzieH | last post by:
Hi everyone. I'm creating a database that holds the data for a residential complex. Each month the latest electricity and water readings are taken. I need to calculate the variance and the variance...
1
1183
by: loide25 | last post by:
Write a C++ program that will calculate and print the sum, mean, variance, and standard deviation of 7 numbers. The numbers must be input as data. This input data must be printed by the program. If...
0
6998
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7163
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6884
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
4904
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1416
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
651
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
287
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.