#include <iostream>
#include <iomanip>
#include <cstdlib>
using namespace std;
float serie(float , int);
int main(){
float xx;
int nn;
do {
cout<<"Ingrese x=";cin>>xx;
} while ( (xx>=1) || (xx<=0));
do{
cout<<"Ingrese n=";cin>>nn;
} while(nn<=0);
cout<<"Serie= "<<serie(xx,nn)<<endl;
system("PAUSE");
}
float serie(float x, int n){
float suma=0;
float termino=1;
suma=termino;
for (int i=1;i<=n;i++){
termino*=x;
suma+=termino;
}
return suma;
}
#include <iostream>
#include <cstdlib>
#include <cmath>
using namespace std;
float hipo1(float , float);
void hipo2(float , float, float &);
int main(){
float a,b,c;
cout<<"a=";cin>>a;
cout<<"b=";cin>>b;
cout<<"c="<<hipo1(a,b)<<endl;
hipo2(a,b,c);
cout<<"c="<<c<<endl;
system("PAUSE");
}
float hipo1(float a, float b){
return sqrt(pow(a,2.0f)+pow(b,2.0f));
}
void hipo2(float a, float b, float& c){
c=hipo1(a,b);
}
No hay comentarios:
Publicar un comentario