none
C to MIPS RRS feed

  • Question

  •   int number, counter, mask;

      

      printf("Enter an integer in decimal number system\n");

      scanf("%d", &number);

      printf("%d in binary number system is:\n",  number);

      mask = 1;

      for (counter  = 31;  counter  >= 0;  counter --)

      {

        int temp =  number  >>  counter;

     

        if ((temp & mask) == 1)

          printf("1");

        else

          printf("0");

      }
    Friday, October 4, 2019 9:00 PM

All replies

  • Did you have a question?

    Tim Roberts | Driver MVP Emeritus | Providenza & Boekelheide, Inc.

    Sunday, October 6, 2019 7:01 AM
  • Hello,

    to see the assembly code, set the /FA or /FAs compiler option: go to Project Settings -> C/C++ -> Output Files -> Assembly Output.

    Regards, Guido

    Monday, October 7, 2019 6:15 AM
  • Hello,

    If your issue is solved, please "Mark as answer" or "Vote as helpful" post to the appropriate answer , so that it will help other members to find solution quickly if they faces similar issue. If not, please feel free to contact us.

    Best Regards,

    Suarez Zhou

    Monday, October 14, 2019 8:22 AM