Question

Use C code please! Write the function definition for a function called FindQuo that takes one...

Use C code please!

Write the function definition for a function called FindQuo that takes one argument of type double (arg1 ) and returns a double.  The purpose of the function is to calculate the quotient of arg1 divided by a double (num) that will be entered by the user.

Inside the function declare ask and get a double value from the user called num

Use a loop (while or do/while) to ensure that the user does not enter a 0.0.

You do not want to divide by 0.

  • if both arg1 and num are both positive values, print the message "the result is positive"
  • if both arg1 and num are both negative values, print the message "the result is positive"
  • If arg1 is negative and num is positive, print the message "the result is negative"
  • If arg1 is positive and num is negative, print the message "the result is negative"

Divide arg1 by num and return the result

Homework Answers

Answer #1
#include<stdio.h>

double FindQuo(double arg1){
   double num;
   printf("Enter value for num: ");
   scanf("%lf",&num);
   while(num==0.0){
      printf("Enter value for num: ");
      scanf("%lf",&num);
   }
   if(arg1>=0 && num>0){
      printf("the result is positive\n");
   }
   if(arg1<0 && num<0){
      printf("the result is positive\n");
   }
   if(arg1<0 && num>0){
      printf("the result is negative\n");
   }
   if(arg1>=0 && num<0){
      printf("the result is negative\n");
   }
   return arg1/num;
}

int main(){
   printf("%lf",FindQuo(5));
   return 0;
}

Know the answer?
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
Similar Questions
In C: write the function definition for a function called COMPOSITENUM that takes one double argument...
In C: write the function definition for a function called COMPOSITENUM that takes one double argument called num. The function will declare, ask and get another double from the user. Compare the double entered by the user to NUMband return to a 0 if they are the same, a -1 if num is less than the double entered by the user and 1 if it is greater.
Write a C# source code. Write a function called CircArea() that finds the area of a...
Write a C# source code. Write a function called CircArea() that finds the area of a circle. It should take an argument of type double and return an argument of the same type. Write a Main() method that gets a radius value from the user, calls CircArea(), and displays the result.
**C code only In this part, you will write a simple user-defined function that prints a...
**C code only In this part, you will write a simple user-defined function that prints a message. This function does not require any parameters or return value. The purpose is simply to get you started writing functions.Open repl project Lab: User-Defined Functions 1. Write a program that calls a function. This function should do the following: 1.Ask the user their name 2. Print a "hello" message that includes the user's name Example output: Please enter your name: ​Mat Hello, Mat!...
Write a function in c using #include <stdio.h> that takes a one-dimensional integer array and returns...
Write a function in c using #include <stdio.h> that takes a one-dimensional integer array and returns the index of the first occurance of the smallest value in the array. Your function must be able to process all the elements in the array. Create a function prototype and function definition (after the main function). Your main function should declare a 100 element integer array. Prompt the user for the number of integers to enter and then prompt the user for each...
write a c++ program A class called car (as shown in the class diagram) contains: o...
write a c++ program A class called car (as shown in the class diagram) contains: o Four private variables: carId (int), carType (String), carSpeed (int) and numOfCars (int). numOfCars is a static counter that should be  Incremented whenever a new Car object is created.  Decremented whenever a Car object is destructed. o Two constructors (parametrized and copy constructor) and one destructor. o Getters and setters for the Car type, ID, and speed. And static getter function for numOfCars....
PYTHON: Write a function called keepShouting. This function does not need any input parameters. The function...
PYTHON: Write a function called keepShouting. This function does not need any input parameters. The function should simply repeat whatever the user enters but in all capitals! The function should ask the user to enter a phrase. The phrase then should be capitalized and printed to the screen. If the user just hits return (which will produce the empty string) then the program should stop. Hint: Use a while loop and string methods # keepShouting() """ The function call should...
Function Example: Write a Python function that receives two integer arguments and writes out their sum...
Function Example: Write a Python function that receives two integer arguments and writes out their sum and their product. Assume no global variables. def writer(n1, n2): sum = n1 + n2 product = n1*n2 print("For the numbers", n1, "and", n2) print("the sum is", sum) print("and the product is", product) ... 1) Create a PYHW2 document that will contain your algorithms in flowchart and pseudocode form along with your screen shots of the running program. 2) Create the algorithm in both...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in...
Part A. Input Validation (Name your C program yourLastName_yourFirstName_Lab4a.c) 1. Place the code you developed in Lab 2 to obtain a diameter value from the user and compute the volume of a sphere (we assumed that to be the shape of a balloon) in a new program, and implement the following restriction on the user’s input: the user should enter a value for the diameter which is at least 8 inches but not larger than 60 inches. Using an if-else...
CAN YOU PLEASE WRITE THIS CODE IN A DIFFERENT WAY 'EASIER AND BETTER' QUESTION Using C++...
CAN YOU PLEASE WRITE THIS CODE IN A DIFFERENT WAY 'EASIER AND BETTER' QUESTION Using C++ 11. Write a function that will merge the contents of two sorted (ascending order) arrays of type double values, storing the result in an array out- put parameter (still in ascending order). The function shouldn’t assume that both its input parameter arrays are the same length but can assume First array 04 Second array Result array that one array doesn’t contain two copies of...
Subject- ( App Development for Web) ( language C#, software -visual studio) Exact question is-Firstly the...
Subject- ( App Development for Web) ( language C#, software -visual studio) Exact question is-Firstly the console calculator is created which perform multiply,divide,sub and add, operation and it accept all type of data (divide by 0 case as well ).Now the main motive is to create the library project from the console calculator project .Than we have to create a unit test project which test the functionality of added library.Make test like Test 1. multiply two positive number,Test 2. Add...