Write a prototype for a function sumnavg that has three type

Write a prototype for a function sum_n_avg that has three type double input parameters and two output parameters. The function computes the sum and the average of its three input arguments and relays its results through the output parameters. Determine the following information about a value passed in as a parameter. Is the value a multiple of 7, 11 or 13? The sign of the value (-1 if it is negative. 0 if it is 0 and 1 if the value is positive). You should write a function with four type int parameters, one input parameter (the value) and three other output parameters. The function should send back the answers to these three questions in the three output parameters of the function. Some sample input data might be: 104 3773 13 121 77 30751. What is the difference in meaning between x3 and x[3]?

Solution

1.

void sum_n_avg(double x,double y,double z,double *sum,double *avg);

pointers *sum and *avg can be used as output parameters.

2.

#include <stdio.h>

int check(int num, int *multiple7 ,int *multiple11 ,int *multiple13)   
{
  
   if(num % 7 == 0) //check if dividing number by 7 results in 0 remainder ,multiple of 7
       *multiple7 = 1;
   else
   *multiple7 = 0;
  
  
  
   if(num % 11 == 0) //check if number is multiple of 11
       *multiple11 = 1;
   else
   *multiple11 = 0;
  
  
   if(num % 13 == 0) //check if number is multiple of 13
       *multiple13 = 1;
   else
   *multiple13 = 0;
  
   if(num < 0) //check if number is negative,positive or 0 return the approriate values
   return -1;
   else if(num == 0)
   return 0;
   else if(num > 0)
   return 1;
  
}
int main()
{
   int number,multiple7,multiple11,multiple13,sign;
  
printf(\"Enter the number to check\");
   scanf(\"%d\",&number);
  
   sign = check(104,&multiple7,&multiple11,&multiple13); //function call
  
   if(sign == -1) //display if number is negative,positive or 0
   printf(\"\ The number is negative\");
   else if(sign == 0)
   printf(\"\ The number is 0\");
   else if(sign ==1)
   printf(\"\ The number is positive\");
  
   if(multiple7 == 1) //displays if number is multiple of 7,11 or 13
   printf(\" and is multiple of 7\");
   if(multiple11 == 1)
   printf(\" and is multiple of 11\");
   if(multiple13 == 1)
   printf(\" and is multiple of 13\");
   return 0;
}

output:

3.

x3 is ordinary variable name but x[3] is an array element at index 3. x[3] is part of array x [];

 Write a prototype for a function sum_n_avg that has three type double input parameters and two output parameters. The function computes the sum and the average
 Write a prototype for a function sum_n_avg that has three type double input parameters and two output parameters. The function computes the sum and the average

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site