Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Semana 4 - Ejercicio 10
- Diseñe un programa que acepte un número p y muestre los primeros p elementos de la sucesión: n^2 + 8
- */
- #include<iostream>
- #include<cmath>
- using namespace std;
- int main()
- {
- float p;
- do{
- cout<<"Ingrese un numero entero y positivo: ";
- cin>>p;
- }
- while(int(p)!=p or p<0);
- for(int i=0 ; i<p ; i++){
- cout<<"n"<<i<<": "<<pow(i,2)+8<<endl; // Evaluamos 'i' en la sucesion dada
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement