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

Hey guys i got some questions I need help with that I am not sure about in C! Th

ID: 3760989 • Letter: H

Question

Hey guys i got some questions I need help with that I am not sure about in C! Thanks!

What is the output of the following code?

9. int a[5]={4,1,3,7};

int total=0,j;

for (j=0;j<5;j++){

            total+=a[j];

}

printf(“The total is %d”,total);

I'm pretty sure this one is a compliation error but let me know if I am wrong!

10. Given the following declaration: int a = 2; int b = 7; int *p = &a; int *q =&b;

       What is the value of each of the following expressions? For (a), (b), and (c), all variables will be set back to their original values.

a.- - a;

b.++ (*q);

c.*q + *p;

11.

Write the following functions:

void swap (int *p, int *q);

when passed the address of two variables, swap should exchange their values.

12.

Write a function that verifies if a given number exists in an array of floats. The function is supposed to return the first position in where the number is encountered. If the given number does not exist, the function returns –1.Then write a program that asks the user to enter an array of floats and calls the function.

The prototype of the function should be like:

int Search (floats a[ ] , int n, float number)

Example:

Consider the following array of floats

2.1       1          9          -14      17.3    5.9       9          17

0          1          2          3          4          5          6          7

If the number to be searched is 5.4 the function returns –1

If the number to be searched is 9 the function returns 2

13.

Write a program using array that asks user to input 10 numbers, then calculates the average of those numbers and finds out the total number that is greater or equal to the average. For example, you have input 10 numbers as: 1,2,3,4,5,-1,-2,-3,-4,-5. The average is 0. The total number that is greater or equal to the average is 5 which are 1,2,3,4,5.

You have to use the loop to do this problem.

Explanation / Answer

int Search (floats a[ ] , int n, float number)