Question

Write a C program as follows:

  • Single source code file
  • Calls a function with an arbitrary name (i.e. you name it) that accepts two arrays of the same size
  • The function should add each element in the arrays together and place the values in a third array
  • Each array element, each array address, and the sum are printed to the screen in tabulated format with headersASSIGNMENT INFORMATION Due Date Saturday, March 2, 2019 11:59 PM Points Possible 20 View Rubric Write a program as follows: .I also would like to request that LOTS of comments be included, as I need help understanding this problem.  
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution:

#include<stdio.h>
int n;
void main()
{
   int a[100],b[100],i;
   void arraysum();
   printf("Enter the size of the arrays:");
   scanf("%d",&n);
   printf("Enter the %d values into array1\n",n);
   for(i=0;i<n;i++)
       scanf("%d",&a[i]);
   printf("Enter the %d values into array2\n",n);
   for(i=0;i<n;i++)
       scanf("%d",&b[i]);
   arraysum(a,b);
}
void arraysum(int a[],int b[])
{
   int c[100],i;

   for(i=0;i<n;i++)
   {
       c[i]=a[i]+b[i];
   }
   printf("\t\tA1 Value\tA1 Address\tA2 Value\tA2 Address\t Sum");
   printf("\n===========================================================================================");
   for(i=0;i<n;i++)
   {
       printf("\nElement %d:\t %d\t\t%u\t %d\t\t%u\t %d",i,a[i],&a[i],b[i],&b[i],c[i]);
   }
   printf("\n");
}

Output:

Activities Terminal▼ Sun 09:19 bhaswanth@jaywanth: File Edit View Search Terminal Help bhaswanth@jaywanth:- gcc -w array.c bh

  
  

Add a comment
Know the answer?
Add Answer to:
Write a C program as follows: Single source code file Calls a function with an arbitrary...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C program as follows: Single source code file Requests the user to input two...

    Write a C program as follows: Single source code file Requests the user to input two integer numbers Requests the user to make a choice between 0 (add), 1 (subtract), or 2 (multiply) Declares three separate functions Uses a pointer to these three functions to perform the requested action Outputs the result to the screen Submit your program source code file to this assignment. Sample Output Enter first integer number: 15 Enter second integer number: 10 Enter Choice: 0 for...

  • I need a c++ code please. 32. Program. Write a program that creates an integer constant...

    I need a c++ code please. 32. Program. Write a program that creates an integer constant called SIZE and initialize to the size of the array you will be creating. Use this constant throughout your functions you will implement for the next parts and your main program. Also, in your main program create an integer array called numbers and initialize it with the following values (Please see demo program below): 68, 100, 43, 58, 76, 72, 46, 55, 92, 94,...

  • c++ program8. Array/File Functions Write a function named arrayToFile. The function should accept three arguments:...

    c++ program8. Array/File Functions Write a function named arrayToFile. The function should accept three arguments: the name of a file, a pointer to an int array, and the size of the array. The function should open the specified file in binary mode, write the contents of the array to the file, and then close the file. Write another function named fileToArray. This function should accept three argu- ments: the name of a file, a pointer to an int array, and the size...

  • Prepare a C program that is a single source code file that declares at least one...

    Prepare a C program that is a single source code file that declares at least one external variable, and initializes the variable. Then performs a loop of at least 10 iterations that calls a function, then increments the external variable. The function uses a static variable, prints both the external variable and the static variable, then increments the static variable.

  • Write a program **(IN C)** that displays all the phone numbers in a file that match the area code...

    Write a program **(IN C)** that displays all the phone numbers in a file that match the area code that the user is searching for. The program prompts the user to enter the phone number and the name of a file. The program writes the matching phone numbers to the output file. For example, Enter the file name: phone_numbers.txt Enter the area code: 813 Output: encoded words are written to file: 813_phone_numbers.txt The program reads the content of the file...

  • Language C Code Write a program that takes two integer arrays (A and B) and sums...

    Language C Code Write a program that takes two integer arrays (A and B) and sums them together (element wise). A third array to accept the result should be passed in as the output argument. Assume the arrays are all the same size. The argument N is the size of the arrays. Your code should provide a function with the following signature: void array Addition (int A[], int B[], int N, int output[]) { } Your code must also provide...

  • C++ programming language Write a program that asks the user for a file name. The file...

    C++ programming language Write a program that asks the user for a file name. The file contains a series of scores(integers), each written on a separate line. The program should read the contents of the file into an array and then display the following content: 1) The scores in rows of 10 scores and in sorted in descending order. 2) The lowest score in the array 3) The highest score in the array 4) The total number of scores in...

  • Code written in NASM Function called findLargest Write a function called findLargest that receives two parameters:...

    Code written in NASM Function called findLargest Write a function called findLargest that receives two parameters: an unsigned doubleword array and the length of the array. The function must return the value of the largest array member in eax. Preserve all registers (except eax) that are modified by the function. Write a test program in main that calls findLargest three times, each call using a different array with different lengths. Function called countHits Write a function called named countHits that...

  • Python DESCRIPTION Write a program that will read an array of integers from a file and...

    Python DESCRIPTION Write a program that will read an array of integers from a file and do the following: ● Task 1: Revert the array in N/2 complexity time (i.e., number of steps) . ● Task 2: Find the maximum and minimum element of the array. INPUT OUTPUT Read the array of integers from a file named “ inputHW1.txt ”. To do this, you can use code snippet from the “ file.py ” file. This file is provided in Canvas....

  • Main topics: Files Program Specification: For this assignment, you need only write a single-file ...

    C program Main topics: Files Program Specification: For this assignment, you need only write a single-file C program. Your program will: Define the following C structure sample typedef struct int sarray size; the number of elements in this sanple's array floatsarray the sample's array of values sample Each sample holds a variable number of values, all taken together constitute a Sample Point Write a separate function to Read a file of delimited Sample Points into an array of pointers to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT