Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Needs to be written in LC3 assembly language Thanks. This program accepts an int

ID: 3710767 • Letter: N

Question

Needs to be written in LC3 assembly language

Thanks.

This program accepts an integer typed in by the user, verifies that the number is valid, and if it is valid prints the binary version of the number to the display as on the following page As you can see the program rejects any input which doesn't start with a or - sign and prints "The input is invalid. to the display Also any integer values less than -511 or greater than +511 are rejected. Values like +0123 are acceptable When a value is rejected the program loops back and asks for a new number. The program stops after printing out the binary representation of the entered number, with a space between each pair of bits. LC3 Console ncer an inceger betveen -511 and +511: 400 input is invalid. r an integer between -511 and +511: 12345 nput ia invalid. an integer between -511 and +511: +12345 input is invelid. Enter an integer between-511 and+511: -512 he input is invalid. Enter an integer between -511 and +511: +511 Halting the proces80r nter an integer betveen-511 and +511: Halting the processo nter an integer between -511 and +511:-1 Halting the processor Enter an integer beteen -511 and +511:-511 111111000000001 Halting the processor

Explanation / Answer

#include <stdio.h>

int binary_conversion(int);

int main()

{

int num, bin;

printf("Enter a number: ");

scanf("%d", &num);

If (num>=-511 && num<=+511)

bin = binary_conversion(num);

else

{

printf("Number is invalid enter the number again : ");

printf("Enter a number: ");

scanf("%d", &num);

}

printf("The binary equivalent of %d is %d ", num, bin);

}

int binary_conversion(int num)

{

if (num == 0)

{

return 0;

}

else

{

return (num % 2) + 10 * binary_conversion(num / 2);

}

}}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote