miércoles, 8 de abril de 2009

Corrección del Laboratorio 1

En el laboratorio 1 algunos alumnos me preguntaron por el procedimiento para realizar el problema 4, el codigo aca:

#include <stdio.h>
#include <stdlib.h>

int main(void){
    int dato;
    unsigned char byte3, byte2, byte1, byte0;
    
    printf("Ingrese un numero: ");
    scanf("%d", &dato);
    
    /*Inserte su codigo aqui*/    
    byte0=dato&(0xff);
    byte1=(dato>>8)&(0xff);
    byte2=(dato>>16)&(0xff);
    byte3=(dato>>24)&(0xff);
    
    printf("El numero es %#x\n", dato);
    printf("Sus bytes son %#x %#x %#x %#x\n", byte3, byte2, byte1, byte0);
    system("pause");
    return 0;
    }

No hay comentarios:

Publicar un comentario