Facebook
From Eratic Cheetah, 2 Years ago, written in Plain Text.
This paste is a reply to Untitled from Trivial Ibis - go back
Embed
Viewing differences between Untitled and Re: Untitled
#include h>
#include h>

int main()
{
    printf("Enter 3 binaries to convert them to decimals a value and find out if the number is even \n");
    for(int i = 0 ; i < 3 ; i++)
    {
        long long bin = 0, dec = 0;
        scanf("%lld", &bin);
        long long trash = bin , amount = 0;
        while(trash>=1)
        {
            trash = trash / 10;          ///calculatinng the length of the number
            amount++;
        }
        for(int i = 0 ; i < amount ; i++)
        {
            
int num = 0;
            num = bin % 10;
            bin = bin / 10;                 ///converting in line power method
            dec = dec + pow(2 , i) * num;
        }
        printf("%lld \n", dec);
    }
    printf("Enter 3 decimals to convert them to binaries \n");
    for(int i = 0 ; i < 3; i++)
    {
        long long dec = 0 , bin = 0;
        scanf("%lld", &dec);
        int lvl = 0;
        while(dec > 0)
        {
            bin = bin + dec % 2 * pow(10, lvl);      ///converting in column method
            dec = dec / 2;
            lvl++;
        }
        printf("%lld \n", bin);
    }
    printf("Enter 3 heximals to convert them into decimals \n");
    for(int i = 0 ; i < 3 ; i++)
    {
        long long num = 0;
        scanf("%x", &num);                     ///using C language advantages to convert 
0;  /// the number
        printf("%d \n", num);
    }
    printf("Enter 3 decimals to convert them into heximals \n");
    for(int i = 0 ; i < 3 ; i++)
    {
        long long num = 0;
        
number
    
scanf("%d", &num);                     ///using C language advantages to convert the number
        printf("%x 
&num);
    printf("%d is %s 
\n", num);
    }


num , ((num % 2) ? "odd" : "even"));     ///ternary if function

    return 0;
}