lunes, 1 de julio de 2019

Ejercicios En Clase

Arreglo
Código:

#include <iostream>
using namespace std;

int main()
{
int filas, columnas;
char elcar;
cout << "¿Cuantas filas?:\t";
cin >> filas;
cout << "¿Cuantas columnas?:\t";
cin >> columnas;
cout << "¿Que caracter?:\t";
cin >> elcar;
for (int i = 0; i < filas; i++)
{
for (int j = 0; j < columnas; j++)
cout << elcar;
cout << "\n";
}
return 0;

   
}


Arreglos de Capturas
Código:

#include <iostream>

using namespace std;


int main()

{
int edad[10], i;
for (int i = 0; i < 10; i++)
{
cout << "Introduzca edad:\t";
cin >> edad[i];
}
for (i = 0; i < 10; i++)
cout << "las edades son" << edad[i] << endl;
system("pause");
return 0;


   
}

Arreglos de Funciones
Código:

#include <iostream>

using namespace std;

 int const LONG = 16;

int main ()
{
int lista[LONG] = { 5, 2, 4, 9, 14, 4, 3, 2, 85, 11, 45, 25, 12, 45, 6, 99 };
int valor_mayor, i;
valor_mayor = lista[0];
for (i = 0; i< LONG; i++)
{
if (lista[i] > valor_mayor)
{
valor_mayor = lista[i];
}
cout << "El numero mayor de la lista es";
cout << valor_mayor << "\n";
system("pause");

}


Calificación
Código:

#include <iostream>

using namespace std;


int main()
{
char nota;
    cout << "Introduzca valor (A-H) y pulse Intro";
cin >> nota;

switch (nota)
{
case 'A': cout << "Excelente "
<< "Examen superado \n";
break;
case 'B': cout << "Notable";
cout << "Suficiencia\n";
break;
case 'C': cout << "Aprobado\n";
break;
case 'D':
case 'F': cout << "Suspendido\n";
break;
default:
cout << "no es posible esta nota";
}
cout << "Final de programa" << endl;

return 0;



}

Clase
Código:

#include <stdlib.h>

double base = 5.0;
int radio = 2.0;
using namespace std;

void main()
{
cout << "El valor de base es=\t" << base << endl;
cout << "La direccion de base:\t " << &base << endl;
cout << "El tamano base:\t" << sizeof(double) << endl;
"BYTES\n";
cout << "Valor del radio:" << radio << endl;
cout << "Direccion radio es:" << &radio << endl;
cout << "El tamano del radio es:" << sizeof(int) << endl;
"BYTES\n";
system("pause");




}


Cualquier Valor numérico introducido es positivo
Código:

#include <iostream>
#include <string>

using namespace std;

int main()
{
cout << "introduce un numero:\t";
int valor;
cin >> valor;
if (valor < 0);
valor = -valor;
cout << valor << " es positivo " << endl;
system("pause");
return 0;

}


Dialogo
Código:

#include <iostream>
#include<string>

using namespace std;


int main()
{
cout << "DIALOGO";
cout << "\n";
cout << "como te llamas:\t";
string x;
cin >> x;
cout << "\n";
cout << " Que edad tienes " << x << ":\t";
int y;
cin >> y;
cout << "\n";
cout << "Quien descubrio America " << x << ":\t";
int z;
cin >> z;
cout << "\n";
cout << "Ontas  " << x << ":\t";
int w;
cin >> w;
cout << "\n";
system("pause");
return 0;



}


Funciones Constantes
Código:

#include <iostream>
#include <conio.h>

using namespace std;
void f(int a = 10, int b = 20, int c = 30)


{
cout << "a=" << a << endl;
cout << "b=" << b << endl;
cout << "c=" << c << endl;
}
void main (void)
{
f();
f(1);
f(1, 5);
f(1, 2, 3);
cout << "Pulse ENTER para continuar....";
system("pause");




}


Holas Infinitos
Código:

#include <iostream>

using namespace std;

int main()
{
int contador = 0;
int max;

cout << "cuantos Holas quieres?:\t";
cin >> max;
for (;;)
{
if (contador < max)
{
cout << "Hola!....\n";
contador++;
}
else
break;
}
return 0;

    
}


IVA de un Producto
Código:

#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
double a, b, c, i, t;
string p;
cout << "Ingrese el producto: ";
cin >> p;
cout << "Ingrese cantidad de Producto: ";
cin >> a;
cout << "Ingrese el precio: ";
cin >> b;
c = a * b;
cout << " la valor es:" << c << endl;
i = b * 14 / 100;
cout << " El iva  es:" << i << endl;
t = c + i;
cout << "El total a pagar es de :" << t << endl;
return 0;
}

Operaciones Básicas
Código:

#include <iostream>
#include<stdlib.h>
#include<math.h>

using namespace std;

int main()
{
float A, B, S, R1, R2, D1, D2, M;

    cout << "Escriba primer numero:\n";
cin >> A;
cout << "Escriba segundo numero\n";
cin >> B;
S= A + B;
R1= A - B;
R2= B - A;
D1= A / B;
D2= B / A;
M= (A * B);

cout << "la suma es:\t" << S << endl;
cout << "\n" << endl;
cout << "La resta de:\t" << A << "-" << B << " = " << R1 << endl;
cout << "\n" << endl;
cout << "la resta de:\t" << B << "-" << A << " = " << R2 << endl;
cout << "\n" << endl;
cout << "La division de:\t" << A << "/" << B << " = " << D1 << endl;
cout << "\n" << endl;
cout << "La division de:\t" << B << "/" << A << " = " << D2 << endl;
cout << "\n" << endl;
cout << "la multiplicacion es:\t" << M << endl;
cout << "\n" << endl;

system("pause");
return 0;


  
    


}


Promedio
Código:

#include <iostream>



using namespace std;
double media(double x1, double x2)


{
return (x1 + x2) / 2;
}
void main()
{
double N1, N2, M;
cout << "Dame 2 valores:\t";
cin >> N1 >> N2;
M = media(N1, N2);
cout << "Media = " << M << endl;
}


Suma de Datos
Código:

#include <iostream>

using namespace std;
const int num = 8;

int main()
 
{
int nums[num];
int total = 0;
for (int i = 0; i < num; i++)
{
cout << "por favor, Introduzca el numero";
cin >> nums[i];
total += nums[i];
}
cout << "el total de numero es" << total << endl;
system("pause");


    
}

Valor Menor
Código:

#include <iostream>

using namespace std;

int const LONG = 16;

int main()
{
int lista[LONG] = { 5, 2, 4, 9, 14, 4, 3, 2, 85, 11, 45, 25, 12, 45, 6, 99 };
int valor_menor, i;
valor_menor = lista[0];
for (i = 0; i < LONG; i++)
{
if (lista[i] < valor_menor)
{
valor_menor = lista[i];
}
cout << "El numero menor de la lista es";
cout << valor_menor << "\n";
system("pause");

}


Volumen del Cono
Código:

#include <iostream>
using namespace std;

const float PI = 3.1416;
inline float vcono(float radio, float altura)
{
return((PI * (radio * radio) * altura) / 3.0);
}
int main()
{
float radio, altura, V;
cout << "radio del cono= \t";
cin >> radio;
cout << "altura del cono= \t";
cin >> altura;
V = vcono(radio, altura);
cout << "El volumen del cono es= \t" << V;
return 0;
}


Área de Triangulo


Área de Círculo




No hay comentarios.:

Publicar un comentario

Ejercicios Link Unidad No.3 Lenguaje Ensamblador

https://mega.nz/#F!30lAhSCB !eJSPm_L1GaETO7qZ1FmiQg *Cambia todas las letras a minúsculas *CBW Y CWD *Definición del Segmento de datos ...