Lab 6:

screen1

screen2

Objective:

For this laboratory experiment, the objective was to pack 4 characters into an unsigned long integer, and be able to call it back up upon request from the user.

#include
#include
using namespace std;
int main()
{

int x;
long a;
long b;
long c;
long d;
long o;
int r;
int y;

    cout<<endl<<"    Choose An Option: "<<endl<<"1 = Packing"<<endl<<"2 = Exit"<<endl<<endl<>x;
    
    if(x ==1){
        cout<<endl<<"    Packing"<<endl<<"Enter any 4 characters..."<>hex>>a,b,c,d;    
        o = o | 0;
        a = (a & o) << 5;
        b = (b & o) << 3;
        c = (c & o) << 1;
        d = (d & o);
            
        cout<<endl<<"Numerical Value:  "<<o<<endl;
        cout<<endl<<"    Do you wish to Un-Pack now? Type 'Y' to continue, else 'N'..."<>r;
        if(r = y){
        cout<<endl<<hex<<o<<endl;
        }
        else{
            exit(0);
        }
    
    }    
    
    else if(x==2){
        cout<<endl<<"    EXITING..."<<endl<<endl;
        exit(0);
    }



return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *