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

Easy68K assembly only please!! Thank you! Please initialize an array [5, 0, 12,

ID: 3865745 • Letter: E

Question

Easy68K assembly only please!! Thank you!

Please initialize an array [5, 0, 12, 3, 8, 21, 1, 14, 2, 16] and perform the following operations on this array.

You need to use subroutine and branch to finish this question. There should be 3 major subroutines “a”, “b” and “c” in the program, one for each requirement given below:

Subroutine “a”: Keep loading numbers from keyboard until the input is 0 or 1. Hint: load the input from keyboard. Check whether the input is 0 or 1, and ask user to load another input if it’s neither 0 nor 1. Store the value only when it’s 0 or 1 and continue to part b

Subroutine “b”: Go through all the elements and pass current odd/even number to subroutine “c” for display. Hint: find out all odd/even elements in the initialized array. That is, if the stored input is 0, use the subroutine “c” to print out ONLY the elements with odd values (5, 3, 21, 1). If the stored input is 1, use the subroutine “c” to print out ONLY the elements with even values (0, 12, 8, 14, 2, 16)

Subroutine “c”: Print out value passed by subroutine “b”, one in each line. Hint: print out the value from subroutine “b” on separate lines. You need to call this subroutine for 4 or 6 times inside the subroutine “b” to print out odd/even numbers.

Explanation / Answer

#include<studio.h>

/* Function declaration */

void a() ;

void b ( int input , int array [ ] )

void c ( int input ) ;

int main ( ) {

/* An int array with 10 elements */

int array [ 10 ] = { 5, 0, 12, 3, 8, 21, 1, 14, 2, 16};

/* Calling function a */

a ( ) ;

}

/* Function declaration of a */

void a ( ) {

int input ;

printf (" enter the number ") ;

scanf (" %d ", &input);

/* Running loop untill input is 0 or 1 */

while ( input != 0 || input != 1)

{

printf ( " please enter number 0 or 1 " ) ;

   scanf (" %d ", &input);

}

/* Calling function b */

b ( input , array );

}

/* Function declaration of b */

void b ( int input , int array [ ]){

for ( int i = 0 ; i < 10 ; i++)

{

     if ( input == 0 && array[ i ] % 2 ==0)

       {

            /* Calling function c if array element is even */

             printf ( " even elements in array are ") ;

             c ( array [ i ]);

        }

    else

        {

/* Calling function c if array element is odd */

printf ( " odd elements in array are " );

c ( array [ i ]);

        }

}

/* Function declaration of c */

void c ( int input ){

{

     printf ( " %d " , input );

}

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