Está en la página 1de 11

UNIVERSIDAD VERACRUZANA

FACULTAD DE CIENCIAS QUMICAS


INGENIERA QUMICA

ALGORITMOS
EJERCICIOS EN CLASE

SEGUNDO SEMESTRE
GRUPO: 1Q4-II

ALUMNA: KARLA PATRICIA TRIANA LUNA


PROFESORA: GUADALUPE BAUZA MENDOZA

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

SUMA DE DOS NMEROS


/*estructura de un programa en "c", suma de 2 numeros*/
#include <stdio.h>
void main()
{
int a,b,c;
//solicita y lee 1 N
printf("Dame un numero ");
scanf("%d",&a);
//solicita y lee 2 N
printf("Dame otro numero ");
scanf("%d",&b);
//SUMA
c=a+b;
//imprime
printf("La suma es %d\n",c);
}

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

if (a>5 && a<8)


{
printf ("suficiente");
}
if (a>7 && a<10)
{
printf ("muy bien");
}
if (a==10)
{
printf ("excelente");
}
}

PROGRAMA NMERO POSITIVO, NEGATIVO, NULO.


//programa numero positivo, negativo, nulo
#include <stdio.h>
void main()
{
int x;
printf("dame el valor del numero");
scanf("%d",&x);
if(x>0)
printf("positivo");
else
{
if(x<0)
printf("negativo");
else
printf("nulo");
}
3

PROGRAMA CATEGORIA, COSTO, SUELDO, HORAS.


//programa sueldo
#include <stdio.h>
void main()
{
int categoria, costo, sueldo, horas;
printf("que categoria es ud?");
scanf("%d", &categoria);
if (categoria==1)
costo=30;
if(categoria==2)
costo=50;
if (categoria==3)
costo=70;
if(categoria==4)
costo=100;
printf("cuantas hjoras trabajo?");
scanf ("%d", &horas);
sueldo=costo*horas;
printf("su pago es %d\n", sueldo);
}

PROGRAMA TEMPERATURA MAYOR


//programa temperatura mayor
#include <stdio.h>
void main ()
{
int T1, T2, T3;
printf("temparatura 1 ");
scanf("%d", &T1);
4

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);
}
}

PROGRAMA MAYOR CUATRO NUMEROS.


//Programa mayor de 4 numeros
#include <stdio.h>
void main ()
{
int a,b,c,d;
printf("numero 1 ");
scanf("%d", &a);
printf("numero 2 ");
scanf("%d", &b);
printf("numero 3 ");
5

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);
}

PROGRAMA MAYOR DOS NUMEROS


// programa dos numeros mayores
#include "stdio.h"
void main()
{
int a, b;
printf("numero uno ");
scanf("%d", & a);
printf("numero dos ");
scanf("%d", & b);
if(a>b)
printf("el numero mayor es%d\n",a);
else
printf("el numero mayor es%d\n",b);
}

PROGRAMA SUMA Y MULTIPLICACIN


//Programa suma y multiplicacion
#include <stdio.h>
void main( )
8

{
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);
}

SUMA Y MULTIPLICACIN CON X


#include "stdio.h"
void main()
{
int x=5,y=2,h,o,m;
float w=3.2,z=2.5;
h=x+y;
m=x*y;
o=x-y;
printf("los numeros son %d %d %2.1f y %2.1f.\nLa suma es %d+%d=%d, \nla
resta es %d-%d=%d, \nla multiplicacion es %d*%d=
%d",x,y,w,z,x,y,h,x,y,o,x,y,m);
printf("\n%d+%d=%d",x,y,h);
printf("\n%d-%d=%d",x,y,o);
printf("\n%d*%d=%d",x,y,m);
9

10

También podría gustarte