Documente Academic
Documente Profesional
Documente Cultură
APLICADA I
TEMA 1
LABORATORIO #1
// ENTRADA DE DATOS
printf("\n Introduzca el primer numero:");
scanf("%d",&a);
printf("\n Introduzca el segundo numero:");
scanf("%d",&b);
printf("\n Introduzca el tercer numero:");
scanf("%d",&c);
//CALCULO DE LA EXPRESION
resultado = a+b+c+100;
//CALCULO DE LA EXPRESION
printf("El resultado es: %d", resultado);
//DETENER LA EJECUCIÓN PARA OBSERVAR LOS RESULTADOS Y
FINALIZAR.
getch();
}
3) Leer 2 números enteros cualquiera e imprimir el resultado de la siguiente
expresión: (a+b)*(a-b)
#include<stdio.h>
#include<conio.h>
main ()
{
//DECLARACION DE VARIABLES
intresp=0,a,b;
//ENTRADA DE DATOS
printf("\n Ingrese el primer numero: ");
scanf("%d",&a);
printf("\n Ingrese el segundo numero: ");
scanf("%d",&b);
//CALCULO DE LA EXPRESION
resp=(a+b)*(a-b);
//IMPRIMIR EL RESULTADO
printf("\n La respuesta es: %d", resp);
if(x>=100&&x<=999)
{
while(x!=0)
{
dig=dig+(x%10);
x=x/10;
}
printf("La suma de los digitos es: %d", dig);
}
else
{
while(sw!=1)
{
if(x<100||x>999)
{
printf("El numero no tiene tres digitos. \nIngrese de nuevo el numero: ");
scanf("%d",&x);
}
else
{
sw=1;
while(x!=0)
{
dig=dig+(x%10);
x=x/10;
}
printf("La suma de los digitos es: %d", dig);
}
}
}
getch();
}
#include<stdio.h>
#include<conio.h>
main()
{
intnum;
printf("Ingrese un numero: ");
scanf("%d",&num);
if(num==0)
printf("ES NULO");
else
{
if (num>0)
printf("ES POSITIVO");
else
printf("ES NEGATIVO");
}
getch();
}