Documentos de Académico
Documentos de Profesional
Documentos de Cultura
LOGARITMOS
LOGARITMOS
ALGORITMOS
EJERCICIOS EN CLASE
SEGUNDO SEMESTRE
GRUPO: 1Q4-II
TABLA DE CONTENIDO
SUMA DE DOS NMEROS........................................................................................ 2
PROGRAMA CALIFICACIN..................................................................................... 2
PROGRAMA NMERO POSITIVO, NEGATIVO, NULO.............................................3
PROGRAMA CATEGORIA, COSTO, SUELDO, HORAS............................................4
PROGRAMA TEMPERATURA MAYOR.......................................................................4
PROGRAMA MAYOR CUATRO NUMEROS...............................................................5
PROGRAMA DESCUENTO......................................................................................... 7
UN NUMERO DADO.................................................................................................. 8
PROGRAMA MAYOR DOS NUMEROS......................................................................8
PROGRAMA SUMA Y MULTIPLICACIN..................................................................9
SUMA Y MULTIPLICACIN CON X...........................................................................9
PROGRAMA CALIFICACIN
//Programa calificaciones
#include<stdio.h>
void main ()
{
int a;
printf ("dame la calificaion ");
scanf ("%d",&a);
if (a>0 && a<5)
{
printf ("reprobado");
}
2
printf("temperatura 2 ");
scanf("%d", &T2);
printf("temperatura 3 ");
scanf("%d", &T3);
if (T1>T2)
{
if (T1>T3)
printf("temperatura mayor es %d\n",T1);
else
printf("temperatura mayor es %d\n", T3);
}
else
{
if(T2>T3)
printf("temperatura mayor es %d\n", T2);
else
printf("temperatura mayor es %d\n", T3);
}
}
scanf("%d", &c);
printf("numero 4 ");
scanf("%d", &d);
if (a>b)
{
if (a>c)
{
if (a>d)
printf("El mayor es %d", a);
else
printf("El mayor es %d", d);
}
else
{
if (c>d)
printf("El mayor es %d", c);
else
printf("El mayor es %d", d);
}
}
else
{
if (b>c)
{
if (b>d)
printf("El mayor es %d", b);
else
printf("El mayor es %d", d);
}
else
6
{
if (c>d)
printf("El mayor es %d", c);
else
printf("El mayor es %d", d);
}
}
}
PROGRAMA DESCUENTO
//Programa descuento
#include <stdio.h>
void main ()
{
float cantidad, precio, subtotal, monto, rebaja, descuento=0;
printf("Que cantidad compro? ");
scanf("%f", &cantidad);
if(cantidad==10)
descuento=0.05;
if(cantidad==20)
descuento=0.1;
if(cantidad==30)
descuento=0.15;
printf("Cual es el precio? ");
scanf("%f", &precio);
subtotal=cantidad*precio;
rebaja=subtotal*descuento;
monto=subtotal-rebaja;
printf("El total a pagar es %2.2f\n", monto);
}
UN NUMERO DADO
//Programa mayor el primer numero dado
#include <stdio.h>
void main()
7
{
int a,b;
printf(numero uno);
scanf(%d, &a);
printf(numero dos);
scanf(%d, &b);
if(a>b)
printf(mayor a);
}
{
int a,b,x,y;
printf("Dame un numero");
scanf("%d", &a);
printf("Dame el segundo numero");
scanf("%d", &b);
x=a+b;
y=a*b;
printf("la suma de % d y %d es % d, la multiplicacion de %d y % d es %d",
a,b,x,a,b,y);
}
10