Question

3. [30pts] Determine the following information about a value passed in as a parameter. (a) Is...

3. [30pts] Determine the following information about a value passed in as a parameter.
(a) Is the value a multiple of 7, 11 or 13? (b) 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 three type int parameters, one input parameter (the value) and two other output parameters. The function should send back the answers to the two questions above in the output parameters of the function. Some sample input data might be: 104 3773 13 121 77 30751.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

\color{blue}\underline{Solution.c:}

#include<conio.h>
#include<stdio.h>

void checkInput(int value, int *multiple, int *sign){
   if(value%7 == 0 && value%11 == 0 && value%13 == 0){
       *multiple = 1;
   }
   else{
       *multiple = 0;
   }
   if(value == 0){
       *sign = 0;
   }
   else if(value<0){
       *sign = -1;
   }
   else{
       *sign = 1;
   }
}

int main() {
   int value, multiple, sign;
   printf("Enter value: ");
   scanf("%d",&value);
   checkInput(value, &multiple, &sign);
   if(multiple == 1){
       printf("%d is multiple of 7, 11 or 13\n",value);  
   }
   else{
       printf("%d is not a multiple of 7, 11 or 13\n",value);  
   }
   printf("Sign of the value is: %d\n",sign);
  
   getch();
   return 0;
}

\color{red}\underline{Output1:}

\color{red}\underline{Output2:}


answered by: ANURANJAN SARSAM
Add a comment
Know the answer?
Add Answer to:
3. [30pts] Determine the following information about a value passed in as a parameter. (a) Is...
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
  • (Please use C language, not C++) Determine the following information about each value in a list...

    (Please use C language, not C++) Determine the following information about each value in a list of positive integers. a. Is the value a multiple of 7, 11, or 13? b. Is the sum of the digits odd or even? (parameter output returns 0 for even, 1 for odd) c. Is the value a prime number? (parameter output returns 0 nonprime, 1 for prime) Use an output file for results. The goal is to implement both pass by value and...

  • C+ using pointers 2. Determine the following information about each value in a list of positive...

    C+ using pointers 2. Determine the following information about each value in a list of positive integers. Is the value a multiple of 7, 11, or 13? a. b. Is the sum of the digits odd or even? (parameter output returns 0 for even, 1 for odd) Is the value a prime number? (parameter output returns 0 nonprime, 1 for prime) c. You should write three functions: 1)input, 2) processing, 3)output 1) Input wil have one output parameter of type...

  • For each of the following function calls, please write if the parameter is passed by value...

    For each of the following function calls, please write if the parameter is passed by value or passed by reference to a hypothetical function 'myFunc'. You should briefly explain why to get full credit. Q7.1 3 Points int num = 5; myFunc(num); Q7.2 3 Points int num = 5; myFunc(&num); Q7.3 3 Points int num[] = {5}; myFunc(num); Q7.4 3 Points int num[] = {5,6,7,8,9}; myFunc(num); Q7.5 3 Points char name[6] = "Hello"; myFunc(name);

  • write C code that uses pointers, arrays, and C strings. 3. Write a function called pow_xy....

    write C code that uses pointers, arrays, and C strings. 3. Write a function called pow_xy. The function should be passed 2 parameters, as illustrated in the prototype below. int pow_xy(int *xptr, int y); Assuming that xptr contains the address of variable x, pow_xy should compute x to the y power, and store the result as the new value of x. The function should also return the result. Do not use the built-in C function pow. For the remaining problems,...

  • C++ Code Pass By Reference Practice Write the following functions for basic array operations based on...

    C++ Code Pass By Reference Practice Write the following functions for basic array operations based on the function descriptions given below. Write the following functions for basic array operations based on the function descriptions given below. FindMinArray: This function will search an array of integers (passed to the function as a parameter) for its minimum value, then return that value. SumArray: This function will sum an array of integers (passed to the function through a parameter) then return that sum....

  • help Question 12 (20 points) Write a function named inverse that takes a single parameter, a...

    help Question 12 (20 points) Write a function named inverse that takes a single parameter, a dictionary. In this key is a student, represented by a string. The value of each key is a list of courses, each represented by a string, in which the student is enrolled. dictionary each The function inverse should compute and return a dictionary in which each key is a course and the associated value is a list of students enrolled in that course For...

  • _28. Using the following function prototype which statement about the argument passed to parameter Als true....

    _28. Using the following function prototype which statement about the argument passed to parameter Als true. void F(const int A[], int Cnt): A. The argument is modified when changes are made to parameter A in function F. B. The argument passed to parameter A must always have the same number of elements, every time function Fis invoked. C. Changes can not be made to parameter A in function F. D. Every element of the argument passed to parameter A must...

  • •The multiplication operator works by summing some value, x, by another value, y. Write a function...

    •The multiplication operator works by summing some value, x, by another value, y. Write a function definition called multiply that takes two integer parameters to perform the operation described. Return the answer to the calling function. •Write a function called randCount with no parameters. The function should randomly generate 5 numbers between 8 to 15 and counts how many times a multiple of 2 occurred. Return the answer to the calling function. •Write a function called summary that takes as...

  • Write a function (subroutine) that inputs a data value in register r0 and returns value in...

    Write a function (subroutine) that inputs a data value in register r0 and returns value in r0. The function returns y 5 a 1 bx 1 cx2, where a, b, and c are parameters built into the function (i.e., they are not passed to it). The subroutine also performs clipping. If the output is greater than a value d, it is constrained to d (clipped). The input in r0 is a positive binary value in the range 0 to 0xFF....

  • COSC 112 Test #3 Spring 2019 20. It is not necessary to specify the parameter name...

    COSC 112 Test #3 Spring 2019 20. It is not necessary to specify the parameter name in the parameter list of a function prototype even 21. Which of following is not a situation when reference parameters are useful? though there is a default parameter. (True/False) a. When you don't want to have side effects b. When you need to change the actual parameter c. When you need to return more than one value d. When you want to save memory...

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
ADVERTISEMENT