Advertisement
Abelsor

Semana 4 - Ejercicio 10

Feb 23rd, 2022
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. /*
  2.                         Semana 4 - Ejercicio 10
  3.     Diseñe un programa que acepte un número p y muestre los primeros p elementos de la sucesión: n^2 + 8
  4. */
  5.  
  6. #include<iostream>
  7. #include<cmath>
  8.  
  9. using namespace std;
  10.  
  11. int main()
  12. {
  13.     float p;
  14.    
  15.     do{
  16.         cout<<"Ingrese un numero entero y positivo: ";
  17.         cin>>p;
  18.     }
  19.     while(int(p)!=p or p<0);
  20.  
  21.     for(int i=0 ; i<p ; i++){
  22.         cout<<"n"<<i<<": "<<pow(i,2)+8<<endl;   // Evaluamos 'i' en la sucesion dada
  23.     }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement