Exercícios c++
Curso: Engenharia Civil
Disciplina: Computação, Algoritmos e Programação I
Professor: Claudio Caruso
Nome: Karine Diniz Matricula: Turma: 1B12 Tarefa: Complementar 10A
10.6 #include <cstdlib>
#include <iostream> using namespace std; double exibir (int n)
{
int i; for (i=1; i<=n; i++) cout << 3*i-1 << endl;
}
int main(int argc, char *argv[])
{
int n; cout << "n = "; cin >> n; exibir(n); cout << n << endl; system("PAUSE"); return EXIT_SUCCESS;
}
10.10
#include <cstdlib>
#include <iostream>
#include <cmath> using namespace std; double exibir (double x, int n);
{
int i; for (i=1; i<=n; i++) cout << pow(x, 2*i) << endl;
}
int main(int argc, char *argv[])
{
double x; int n; cout << "x = "; cin >> x; cout << "n = "; cin >> n; exibir(x, n); cout << n << endl; system("PAUSE"); return EXIT_SUCCESS;
}
10.14
#include <cstdlib>
#include <iostream>
#include <cmath> using namespace std; double funcao (int n)
{
int i; for(i=1; i<=n; i++) cout << (exp(2.0*i-1.0) - pow(2.0*i-1.0, 2.0)) / 2.0 << endl;
}
int main(int argc, char *argv[])
{
int n; cout << "n= " ;cin >> n; cout << endl; funcao(n); cout << endl; system("PAUSE"); return EXIT_SUCCESS;
}
10.21
#include <cstdlib>
#include <iostream>
#include <cmath> using namespace std; double funcao (int n, double x)
{
int i; double s; s = 0; for (i=1; i<=n; i++) s = s + (1*i+1) * pow(x, 4*i-2) / (3*i-1); return s;
}
int main(int argc, char *argv[])
{
int n; double x, s; cout << "n =