top of page

LIBRERÍAS 

<cassert> 

#include <iostream>

#include<math.h>

#include <cassert>

 

#ifdef assert

#undef assert

#endif

#ifdef NDEBUG

#define assert(x) ((void)0)

#else

#define assert(x) \

if (! (x)) \

{ \

std::cout << "ERROR-> Assertion " << #x << " failed\n"; \

std::cout << " on line " << __LINE__ << "\n"; \

std::cout << " in file " << __FILE__ << "\n"; \

}

#endif

 

 

int main (int argc, char * const argv[]) {

    

    std::cout << "Uso de assert" << std::endl ;

 

int a,b,c;

 

std::cout << "Numero 1: ";

std::cin  >> a;

 

std::cout << "Numero 2: ";

std::cin  >> b;

 

assert( b != 0 );  // Se agrega una aserción 

   

c = a / b;

 

std::cout << "Resultado: " << c << std::endl;

 

    return 0;

}

<cctype> 

  1. #include <iostream>

  2. #include<math.h>

  3. #include<cctype> 

  4. using namespace std;

  5.  

  6. int main()

  7. {

  8.    string word;

  9.  

  10.    cout<<"Enter the word: ";

  11.    cin>>word;

  12.  

  13.    int cont = 0;

  14.  

  15.    for(int i=0 ; i<word.length(); i++)

  16.    {

  17.       if(isupper(word[i])) // Si quiero ver las minusculas es con islower(word[i])

  18.       {

  19.           cont++;

  20.       }

  21.    }

  22.    cout<<"\nThe word has: "<<cont<<"capital letters"endl;

  23.  

  24.    cin.get();cin.get();

  25.    return 0;

  26. }

  27.  

<cmath>

#include <iostream>

#include <cmath>

 

using namespace std;

 

int main()

{//Inicio Función Main

    double cateto_1;

    double cateto_2;  //Declaración de Variables

    double hipotenusa;

 

    cout<<"ingrese cateto 1:"<<endl;  //Pedir Cateto 1

    cin>>cateto_1; //Guardar Cateto 1

    cout<<"ingrese el cateto 2:"<<endl; //Pedir Cateto 2

    cin>>cateto_2;  //Guardar Cateto 2

    hipotenusa=sqrt((cateto_1*cateto_1+cateto_2*cateto2)); //Uso de la función sqrt Obtener Raíz Cuadrada

                                //Suma y multiplicación de catetos

    cout<<"la hipotenusa es: "<<hipotenusa<<endl<<"adiós :D"; //Mostrar en pantalla el resultado optenido

    

   return 0;

}//Fin Función Main

bottom of page