如何将一个userdefine函数的值用于另一个用户定义函数?代码如下。 [英] How to use the values of one userdefine function into another user define function ? the code is given below .
问题描述
#include<iostream>
#include<cmath>
float mean(float,float,float,float,float);
float sd(float,float,float,float,float,float);
using namespace std;
main()
{
float g,i,j,k,l,m;
mean(i,j,k,l,m);
sd(g,i,j,k,l,m);
}
float mean(float x1,float x2,float x3,float x4,float x5)
{
float me;
cout<<"Enter The Values Of X1, X2, X3, X4 & X5 , To Find The MEAN"<<endl;
cin>>x1>>x2>>x3>>x4>>x5;
me= (x1+x2+x3+x4+x5)/5;
cout<<"Mean Is = "<<me<<endl;
}
float sd(float x,float x1,float x2,float x3,float x4,float x5)
{
float y,sd;
cout<<"Enter The Values Of X, X1, X2, X3, X4 & X5 , To Find The STANDARD DERIVATION"<<endl;
cin>>x>>x1>>x2>>x3>>x4>>x5;
x= (pow ((x1-x),2) + pow ((x2-x),2) + pow ((x3-x),2) + pow ((x4-x),2) + pow ((x5-x),2))/5;
sd= sqrt(x);
cout<<"Standar Derivation of Given Data Is = "<<sd<<endl;
}
我的尝试:
任何人都可以告诉我如何做到这一点。
我想找到MEAN& StANDARAD DERIVATION usin函数
i我试图将mean函数的值用于sd函数
What I have tried:
Can Anyone tell me how i can do that .
am trying to find MEAN & StANDARAD DERIVATION usin functions
i am trying to use the value of " mean " function into " sd " function
推荐答案
就像你调用的一样主要功能。
The same way you called the functions in your main.
请参阅功能C - Google搜索 [ ^ ]。
如何将一个userdefine函数的值用于另一个用户定义函数?代码如下所示。
How to use the values of one userdefine function into another user define function ? the code is given below .
用户定义的函数与任何其他函数完全一样。这是C ++ 101.
User defined functions work exactly like any other functions. This is C++ 101.
float g,i,j,k,l,m;
mean(i,j,k,l,m);
sd(g,i,j,k,l,m);
这些浮点变量是无用的,看起来你试图使用不存在的魔法。它距离它的工作方式还有很远的地方,猜测它的意图是很复杂的。再一次,这是C ++ 101.
您应该尝试真正了解C / C ++的工作原理。
以下是语言作者对C和C ++参考书的链接。注意,C是C ++的祖先,所以知道C对C ++总是有用。
C编程语言 - 维基百科,免费的百科全书 [ ^ ]
https://hassanolity.files.wordpress.com/2013/11/the_c_programming_language_2。 pdf [ ^ ]
http://www.ime.usp。 br / ~pf / Kernighan-Ritchie / C-Programming-Ebook.pdf [ ^ ]
C ++编程语言 [ ^ ]
Those float variables are useless, looks like you try to use a magic that does not exist. It is so far away from the way it works, that it is complicated to guess what was the intend. Once again, this is C++ 101.
You should try to really learn how C/C++ works.
Here is links to references books on C and C++ by the authors of the languages. Note than C is the ancestor of C++, so knowing C is always useful with C++.
The C Programming Language - Wikipedia, the free encyclopedia[^]
https://hassanolity.files.wordpress.com/2013/11/the_c_programming_language_2.pdf[^]
http://www.ime.usp.br/~pf/Kernighan-Ritchie/C-Programming-Ebook.pdf[^]
C++ Programing Language[^]
这篇关于如何将一个userdefine函数的值用于另一个用户定义函数?代码如下。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!