Vous êtes sur la page 1sur 4

Calcular la integral de X^2 con los valores iniciales ingresados por teclado: #include <iostream> using namespace std;

#define integral(X) X*X*X/3 int main() { float a,b; cout<<"Ingrese los limites de la integral: "; cin>>a>>b; cout<<"La integral de X^2 es: "; cout<<integral(a)-integral(b)<<endl; system("PAUSE"); return 0; }

Implementar una funcin que calcule la capacitancia equivalente de 3 capacitores e s serie y luego a continuacin 3 capacitores en paralelo. #include <iostream> #include <iomanip>//para #include <conio.h>//para using namespace std; float sumaserie(float a, float sumaparalelo(float int main() { float c1,c2,c3; cout<<setw(20)<<"Programa que suma capacitores"<<endl<<endl; cout<<endl<<endl; cout<<"capacitores en serie..."<<endl<<endl; cout<<" C1 C2 C3"<<endl; cout<<"-------||---------||--------||------"<<endl<<endl; cout<<"Ingrese los valores de C1:"; cin>>c1; cout<<endl; cout<<"Ingrese los valores de C2:"; cin>>c2; cout<<endl; cout<<"Ingrese los valores de C3: "; cin>>c3; cout<<endl; cout<<"la capacidad equivalente es:"<<endl; sumaserie(c1,c2,c3); getch(); system("cls"); cout<<endl; cout<<"capacitores en paralelo..."<<endl<<endl;; cout<<" | "<<endl; setw() getch() float b, float c); a, float b, float c);

cout<<" ---------------------------- "<<endl; cout<<" | | |"<<endl; cout<<" | | |"<<endl; cout<<" - c1 - c2 - c3"<<endl; cout<<" -"<<endl; cout<<" | | |"<<endl; cout<<" | | |"<<endl; cout<<" ---------------------------- "<<endl; cout<<" | "<<endl<<endl; cout<<"Ingrese los valores de C1:"; cin>>c1; cout<<endl; cout<<"Ingrese los valores de C2:"; cin>>c2; cout<<endl; cout<<"Ingrese los valores de C3: "; cin>>c3; cout<<endl; cout<<"la capacidad equivalente es:"<<endl; sumaparalelo(c1,c2,c3); cout<<endl<<endl; system("PAUSE"); return 0; } float sumaserie(float a, float b, float c) { float ceq; ceq=1/((1/a)+(1/b)+(1/c)); cout<<ceq; } float sumaparalelo(float a, float b, float c) { float ceq; ceq=a+b+c; cout<<ceq; }

Realizar el programa anterior pero con arreglos #include <iostream> #include <iomanip> #include <conio.h> using namespace std; float sumaserie(float a[3]); float sumaparalelo(float a[3]); float c[3]; int main() { cout<<setw(20)<<"Programa que suma capacitores"<<endl<<endl; cout<<endl<<endl; cout<<"capacitores en serie..."<<endl<<endl; cout<<" C1 C2 C3"<<endl; cout<<"-------||---------||--------||------"<<endl<<endl; for(int i=0;i<3; i++) { cout<<"Ingrese c"<<i+1<<" :"<<endl; cin>>c[i]; cout<<endl;

} cout<<"la capacidad equivalente es:"<<endl; sumaserie(c); getch(); system("cls"); cout<<endl; cout<<"capacitores en paralelo..."<<endl<<endl;; cout<<" | "<<endl; cout<<" ---------------------------- "<<endl; cout<<" | | |"<<endl; cout<<" | | |"<<endl; cout<<" - c1 - c2 - c3"<<endl; cout<<" -"<<endl; cout<<" | | |"<<endl; cout<<" | | |"<<endl; cout<<" ---------------------------- "<<endl; cout<<" | "<<endl<<endl; for(int i=0;i<3; i++) { cout<<"Ingrese c"<<i+1<<" :"<<endl; cin>>c[i]; cout<<endl; } cout<<"la capacidad equivalente es:"<<endl; sumaparalelo(c); cout<<endl<<endl; system("PAUSE"); return 0; } float sumaserie(float a[3]) { float ceq,eq=0.0; for(int i=0;i<3; i++) { eq+=(1/a[i]); } ceq=1/eq; cout<<ceq; } float sumaparalelo(float a[3]) { float ceq=0.0; for(int i=0;i<3; i++) { ceq+=a[i]; } cout<<ceq; } Programa que realiza el binomio al cubo mediante una funcin con un archivo binomi oalcubo.h Programa principal: #include <cstdlib> #include "binomioalcubo.h" int main(int argc, char *argv[]) {

float a,b; ESCRIBIR"Programa que opera un biomio al cubo: (a+b)^3"<<SALTAR; ESCRIBIR"Ingrese los valores de a y b respectivamente:"<<SALTAR; LEER a>>b; ESCRIBIR SALTAR; ESCRIBIR "el resultado es: "<<binomiocubo(a,b); ESCRIBIR SALTAR; ESCRIBIR SALTAR; system("PAUSE"); return EXIT_SUCCESS; }

Binomio al cubo.h: #include <iostream> #include <math.h> using namespace std; #define LEER cin>> #define ESCRIBIR cout<< #define SALTAR endl float binomiocubo(float &x, float &y) { float cubo; cubo=pow(x,3)+3*pow(x,2)*y+ 3*pow(y,2)*x+pow(y,3); return cubo; }

Vous aimerez peut-être aussi