jueves, 14 de noviembre de 2013

SEGUNDO CODIGO PRACTICA EJEMPLO



# include <iostream>
# include<windows.h>
using namespace std;
int main()
{
    float v,d,t;
    cout <<" \t PROGRAMA QUE CALCULA DISTANCIA RECORRIDA"<<endl;
   // cin.get();// reemplaza al getche()
   cout <<" Ingresar La Velocidad"<<endl;
   cin>>v;
   cout <<" Ingresar El Tiempo"<<endl;
   cin>>t;
   d=(v*t);
    cout <<" \t\t LA DISTANCIA RECORRIDA ES"<< d << endl;
   system("PAUSE");
}    
// SUMA DE DOS NUMEROS
# include <iostream>
# include<windows.h>
using namespace std;
int main()
{
    float v,d,t;
   cout <<" \t PROGRAMA QUE SUMA 2 NUMEROS"<<endl;
   cout <<" Ingresar Los Valores"<<endl;
   cin>>v >>t;
   d=(v*t);
   cout <<" \t\t LA SUMA ES"<< d << endl;
   system("PAUSE");
}   
//  MULTIPLICACION DE DOS CONSTANTES
# include <iostream>
# include<windows.h>
using namespace std;
int main()
{
    float v=10.26,t;
    int d=3;
 
   t=(v*d);
   cout <<" \t\t LA MULTIPLICACIÓN ES"<<"    "<< t << endl;
   system("PAUSE");
}    

// Declaración De Constantes De Diferentes Tipos De Datos.
# include <iostream>
# include <windows.h>
# define a 2.33
# define b 4.55
using namespace std;
int main()
{
float c=0; 
char mensaje[20] = " Hola Mundo Cruel";// Forma Correcta De Crear Una Constante Tipo Cadena De Carcateres
char pp[2]= "@";// Constante Con Un Solo Caracter
  cout<<" \t OPERACIONES CON DOS CONSTANTES DEFINIDAS EN LAS CABECERAS"<<endl;
  c=(a+b);
  cout<<"\t\t LA RESPUESTA DE LA SUMA DE LAS CONSTANTES ES..... "<<c<<endl;
  cout<<mensaje<<endl;
  cout<<pp<<endl;
  cin.get();
}


SENTENCIA IF ELSE<<<---------------------------
# include <iostream>
# include <windows.h>
# define constante 4.56
# define valor 6.44
using namespace std;
int main()
{
    int a,b;
    cout<<"\t ENTRAR DOS VALORES ENTEROS"<<endl;
    cin>>a>>b;
    if (a>b)
    {
            cout <<"\t EL VALOR MAYOR ES LA VARIABLE AA.."<<a<<endl;
            cin.get();
            }
           
            else
            {
            cout <<"\t EL VALOR MAYOR ES LA VARIABLE BB.."<<b<<endl;
            system("PAUSE");
           
            }
           
            cin.get();
            }