Question #261787

Write a program to:

  1. 1. Read Test 1 and Test 2 marks and store in array test1 and array test2 where each array stores 5
  2. elements.
  3. 2. Total up marks from test1 and test2 arrays and store in array named total.
  4. 3. Print the total marks from array total.

Use pointers to access array members.

Expert's answer

#include <stdio.h>

void print(int *, size_t);

int main() {
  int test1[5], test2[5], total[5];
  printf("Test1:");
  for (size_t i=0; i<5; i++)
    scanf("%d", &test1[i]);
  for (size_t i=0; i<5; i++)
    scanf("%d", &test2[i]);
  for (size_t i=0; i<5; i++)
    total[i]=test1[i]+test2[i];
  print(total, 5);
  return 0;
}

void print(int *total, size_t n) {
  for (size_t i=0; i<n; i++)
    printf("%d ", total[i]);
  printf("\n");
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

LATEST TUTORIALS
APPROVED BY CLIENTS