Question

C language program that needs to be finished. Please go here to locate the given code...

C language program that needs to be finished. Please go here to locate the given code with 5 steps: bit (dot) ly (slash) 2kckkCm

Will give a thumb up!

Homework Answers

Answer #1

CODE

#include <stdio.h>

void swapWithRef ( unsigned char *x, unsigned char *y )

{

unsigned char temp = *x;

*x = *y;

*y = temp;

}

unsigned int ComputeSum ( unsigned int data[ ] , unsigned int len )

{

unsigned int sum = 0 ;

for(int i=0; i<len; i++) {

sum += data[i];

}

return sum;

}

void ComputeSumOfOddNumbers ( unsigned int *ptr, unsigned int len, unsigned int *sum )

{

for (int i=0; i<len; i ++) {

if (ptr[i] % 2 == 0)

*sum += ptr[i];

}

}

void Increment(unsigned int *ptr , unsigned int len )

{

for (int i=0; i<len; i++) {

ptr[i] += 1;

}

}

int main ( )

{

unsigned char x = 'B', y = 'a' ;

printf ( " x = %c y = %c \n", x, y ) ;

swapWithRef(&x,&y) ;

printf ( " x = %c y = %c \n", x, y );

unsigned int data [ ] = { 11, 18, 7, 6 , 9};

// Ideally you should compute len. but it's okay for now.

unsigned int len = 5 ;

printf ( "Sum of all elements %d \n", ComputeSum ( data, len ) ) ;

unsigned int oddSum = 0 ;

ComputeSumOfOddNumbers ( data, len , &oddSum );

printf ( "Sum of all odd numbers %d \n", oddSum ) ;

oddSum = 0 ;

unsigned int *ptr = data ;

Increment ( ptr, len );

int i;

for ( i = 0 ; i < len; i++ )

printf ( "i= %d value = %d \n", i, data[i] );

}

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Perl language and by using VS Code: Write a program that reads a number, adds up...
Perl language and by using VS Code: Write a program that reads a number, adds up the cube of all the digits, and displays the result. Run your code with the following test number: 1242 It should give 81. Please include screenshots of your outputs.
Please Code in Assembly Language Code solution using the provided template AL_Template_Irvine32.asm located towards the bottom...
Please Code in Assembly Language Code solution using the provided template AL_Template_Irvine32.asm located towards the bottom of the question. Debug programs with Visual Studio2017/19. Please add single line or block comments explaining the purpose or functionality of your code statements. Draw Text Colors Write a program that displays the same string in four different colors, using a loop. Call the Set-TextColor procedure from the book’s link library. Any colors may be chosen, but you may find it easiest to change...
Here is a “snippet,” a few lines, taken from a C language program. int a, b,...
Here is a “snippet,” a few lines, taken from a C language program. int a, b, c; float d, e, f; c = a + b; d = e + f; How many distinct opcodes will appear in the machine code compiled from this C snippet and why?
Please Code in Assembly Language Code solution using the provided template AL_Template_Irvine32.asm located towards the bottom...
Please Code in Assembly Language Code solution using the provided template AL_Template_Irvine32.asm located towards the bottom of the question.. Debug programs with Visual Studio2017/19. Please add single line or block comments explaining the purpose or functionality of your code statements. 6.) Random Strings Create a procedure that generates a random string of length L, containing all capital letters. When calling the procedure, pass the value of L in EAX, and pass a pointer to an array of byte that will...
In C language: Partially finished program is given below. The second and third parameters of the...
In C language: Partially finished program is given below. The second and third parameters of the count() function need to be pointer parameters. However, the programmer forgot to write the necessary ampersands and asterisks in the prototype, call, function header, and function code. Add these characters where needed so that changes made to the parameters adults and teens actually change the underlying variables in the main program. #include #define MAX 10 void count( int ages[], int adults, int teens );...
Convert this C++ program exactly as you see it into x86 assembly language: // Use the...
Convert this C++ program exactly as you see it into x86 assembly language: // Use the Irvine library for the print function #include <iostream> // The string that needs to be printed char word[] = "Golf\0"; // Pointer to a specific character in the string char * character = word; //NOTE: This main() function is not portable outside of Visual Studio void main() { // Set up a LOOP - See the while loop's conditional expression below int ecx =...
In assembler code must be a gcd.s file So here is the C code I have...
In assembler code must be a gcd.s file So here is the C code I have written originally for the program. My question is how do I convert it to assembly code? //C code #include <stdio.h> int fibonacci(int n) { if(n <= 2) { return 1; } else { return fibonacci(n-1) + fibonacci(n-2); } } int main(void) { int n; printf("Enter Fibonacci term: "); scanf("%d", &n); printf("The %dth Fibonacci number is %d\n", n, fibonacci(n)); return 0; } Instructions In C...
Please write the code in Python. Write a program/function in any Object-Oriented programming language that will...
Please write the code in Python. Write a program/function in any Object-Oriented programming language that will implement Queue Abstract Data Type with the following functions/methods.  Any build-in/pre-defined Queue function/library (e.g., java.util.Queue in Java) is NOT allowed to use in your code. push(Element):  insert the input Element (e.g., String or Integer in Java) to the end of the queue. pop(): remove the head element of the queue and print the head element on screen. count():  return the total number of elements in the queue...
Please use C++ programming language write a program to convert temperature in Fahrenheit to temperature in...
Please use C++ programming language write a program to convert temperature in Fahrenheit to temperature in celcius.( no comments necessary). get the temperature in Fahrenheit. calculate the temperature in Celsius. and write  the output to screen. Celsius = (5/9) * (F-160)
Write a C++ program to print all the perfect numbers below a certain given number. A...
Write a C++ program to print all the perfect numbers below a certain given number. A perfect number is a number that that is equal to the sum of it's divisors other than itself . For example, 6 and 28 are all perfect numbers. 6 = ( 1+2 +3) 28 = (1+2+4+7+14) Make sure your program conforms to the following requirements: 1. Accept the upper limit from the user (as an integer). (5 points) 2. Make sure the number is...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT