. Write code that defines integer arrays of size n. Write two user-defined funct
ID: 3711844 • Letter: #
Question
. Write code that defines integer arrays of size n.
Write two user-defined functions:
1. The first function takes in three arrays and subtracts the value of the second array from the first and stores the result in the third array
2. The second function takes in two arrays and assigns the values from the second array into the first array
Write code that defines a struct book_t that stores book title, author name, year of publication, genre (“S” for Sci-Fi, “R” for Romance, “F” for Fiction, “N” for Non-Fiction, etc), and cost.
Write two user-defined functions:
1. Initializes an instance (variable) of book_t using user input.
2. Takes in an array of book_t and books (number of books in the array) and returns the count of non-fiction books
Write code uses string library functions strlen, strcpy, strcmp, strcat or strncat
. Write two user-defined functions that:
1. Takes in two parameters – a character array S1 and SIZE (total size of the array) and fills S1 with user input from the keyboard after user is prompted to enter name
2. Takes in two character arrays S1, S2 and returns 0 if the strings are equal
This practice for test, so please asnwer with explain and comments.Thanks
Explanation / Answer
As per Chegg guidelines, if a question of the user contains more than one question then the expert need to answer the first question. As I need to follow the guidelines I am answering the first question. Hope you read the guidelines and understand. :)
#include <stdio.h>
#include <stdlib.h>
void subtract(int first[], int second[], int third[]){
int i;
for(i = 0; i < 5; i++)
third[i] = first[i] - second[i];
printf("The values of the third array are:");
for(i = 0; i < 5; i++)
printf("%d ", third[i]);
}
int main()
{
int first[5] = {4, 7, 8 , 9, 10};
int second[5] = {1, 2, 3 , 4 ,5 };
int third[5];
subtract(first, second, third);
return 0;
}
**Comment for any further queries.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.