Thread: Getting error on Matrix

  1. #1
    Registered User
    Join Date
    Mar 2015
    Location
    Toronto, Ontario, Canada
    Posts
    9

    Getting error on Matrix

    Hello there. I've a problem. I've a code and it works on my linux laptop; however it doesnt work on a matrix server. Im getting error
    Code:
     
    file.c: In function ‘CondCheck’:file.c:40:3: warning: this decimal constant is unsigned only in ISO C90 [enabled by default]
    The code of the programme
    Code:
    #include <stdio.h>
    #include <string.h>
    #include <math.h>
    
    
    
    
    /*DECIMAL TO BINARY CONVERTER*/
    int BinaryConverter (int bina)
    {
        
        int i =0; //Thecounter
        double  co = 2147483647;
        
        for (i=0; i<32; i++)
        {
            
            if(bina>=co) 
            {
                printf("1");
                bina=bina-co;
            }
            else
                printf("0");
            co=co/2;
        /*THE SEPARATOR*/
            if (i == 7 || i == 15 || i == 23)
            printf(" ");
        }
        printf("\n");
        i=0;
    }
    
    
    /*THE CONDTION*/
    int CondCheck (int error)
    {
        while (error < 0 || error > 2147483648)
        {
            printf("\n*** This number is not a valid number, try again ***");
            scanf("%d", &error);
        }
    }
    
    
    /*THE FIBONACHI NUMBERS*/
    int fibonacci (int i, int num2)
    {
        int sum, counter2;
        sum, counter2 =0;
    
    
        while (counter2 < 8)
        {
            sum=i+num2;
            
            if (counter2 == 7)
                printf("%d", sum);
            else
                printf("%d,", sum);
            i=num2;
            num2=sum;
            counter2++;
        }
    }
    
    
    /*THE 30th Fibonachi VALUE*/
    int TheThirty (int i, int num2)
    {
        int sum, counter2;
        sum, counter2 =0;
    
    
        while (counter2 < 29)
        {
            sum=i+num2;
            i=num2;
            num2=sum;
            counter2++;
        }
        return sum;
    
    
    }    
    
    
    /*THE BODY*/
    main()
    {
    
    
        int choice, binary, number1, number2;
    
    
        printf("\nWELCOME TO THE IPC144 MATH UTILITY (by: Anton Elistratov)");
        printf("\n1.) Integer to Binary converter");
        printf("\n2.) Fibonacci generator");
        printf("\n999.) Exit");
        printf("\nEnter selection ---> ");
        scanf("%d", &choice);
        printf("\n");
    
    
        while (choice != 999)
        {
        
            while (choice != 1 && choice != 2 && choice != 999)
            {
                printf("\n***This is not a valid selection, try again *** ");
                scanf("%d", &choice);
            }
    
    
            switch(choice)
            {        
                /*BINARY CONVERTION*/
                case 1:    
                    printf("\nEnter a number between 0 and 2147483647 inclusive: ");
                    scanf("%d", &binary);
                    
                    
                    CondCheck(binary);
                                    
                    
                    BinaryConverter(binary);    
                        
                    break;
            
                case 2:
                    printf("Enter first number: ");
                    scanf("%d", &number1);
                    printf("Enter second number: ");
                    scanf("%d", &number2);
                
                    
                    while (number1 > number2)
                    {
                        printf(" Second number must be greater then first number.\n");
                        printf("Enter first number: ");
                        scanf("%d", &number1);
                        printf("Enter second number: ");
                        scanf("%d", &number2);
                    }
                    
                    printf("%d,", number1);
                    printf("%d,", number2);
                    
                    
                    fibonacci(number1, number2);
                    printf("Fib [30, {%d,%d}] = %d", number1, number2, TheThirty(number1, number2));
                    
                    break;
    
    
                default:
                    printf("\nDefaul in the case\n");
                    break;
    
    
            }
            printf("\nWELCOME TO THE IPC144 MATH UTILITY (by: Anton Elistratov)");
            printf("\n1.) Integer to Binary converter");
            printf("\n2.) Fibonacci generator");
            printf("\n999.) Exit");
            printf("\nEnter selection ---> ");
            scanf("%d", &choice);
            printf("\n");
        }    
    }
    Im just a begginer. What I should do to solve this error?

  2. #2
    Registered User
    Join Date
    Mar 2015
    Location
    Toronto, Ontario, Canada
    Posts
    9
    Quote Originally Posted by qwes3r View Post
    Code:
    /*THE CONDTION*/int CondCheck (int error)
    {
        while (error < 0 || error > 2147483648)
        {
            printf("\n*** This number is not a valid number, try again ***");
            scanf("%d", &error);
        }
    }
    
    Fixed it! I changed the code to
    Code:
    /*THE CONDTION*/
    int CondCheck (int error)
    {
        while (error < 0 || error >= 2147483647)
        {
            printf("\n*** This number is not a valid number, try again ***");
            scanf("%d", &error);
        }
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. matrix run-time error
    By V8cTor in forum C++ Programming
    Replies: 4
    Last Post: 01-13-2015, 09:09 AM
  2. Replies: 2
    Last Post: 05-19-2014, 07:32 PM
  3. Matrix - Logic error?
    By FernandoBasso in forum C Programming
    Replies: 2
    Last Post: 11-23-2011, 11:50 AM
  4. strange matrix error
    By engg in forum C Programming
    Replies: 7
    Last Post: 10-16-2011, 08:01 PM
  5. Error allocating matrix
    By gustavosserra in forum C Programming
    Replies: 5
    Last Post: 09-25-2003, 02:07 PM