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

Part 3- RTL In the Simple Machine reading, the instructions for the Simple Machi

ID: 3729609 • Letter: P

Question

Part 3- RTL In the Simple Machine reading, the instructions for the Simple Machine are detailed, as well as the specification for our register transfer language (RTL). Part of the algorithm necessary for simulating (or microprogramming) the operation of our Simple Machine using RTL was also provided. In this part of the assignment, you will finish this algorithm by adding the clauses necessary for each of the missing instructions. Note that if you choose to use an if statement at any point, you can only compare a register against zero, and the operator can only be equals (=) or less than (

Explanation / Answer

ans :

#include <stdio.h>

#include <math.h>

int main()

{

int low, high, i, temp1, temp2, remainder, n=0, result=0;

printf("enter two numbers(intervals): ");

scanf(" %d %d ", &low, &high);

printf("armstrong numbers between %d an %d are : ", low, high);

for(i=low+1;i<high;++i)

{

temp2=i;

temp1=i;

//number of digits calculation

while(temp1 !=0)

{

temp1 /=10;

++n;

}

//result contains sum of the nth power of its digits

while(temp2 !=0)

{

remainder=temp2 % 10;

result +=pow(remainder,n);

temp2 /=10;

}

//checks if number i is equal to the sum of nth power of its digits

if (result == i) {

printf(" %d " , i);

}

//resetting the values to check armstrong number for next iteration n=0;

result =0;

}

return 0;

}

IF YOU HAVE ANY DOUBTS PLEASE REPLY BACK .THANK YOU.

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