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

Problem: Given a range of values determine how many integers within that range,

ID: 3529744 • Letter: P

Question

Problem: Given a range of values determine how many integers within that range, including the end points, are multiples of a third value entered by the user. The user should be permitted to enter as many of these third values as desired and your output will be the sum of total multiples found. NOTE: THE USE OF USER-DEFINED FUNCTIONS IS REQUIRED ON THIS ASSIGNMENT. The user will always enter integer data. The final example demonstrates the input validation requirements. ? A -1 value will be entered to terminate the third input value entry DO NOT use ARRAY!


I GOT EVERYTHING EXCEPT ****EXAMPLE 2****


Example Execution #1:

Enter the low range value: 5

Enter the high range value: 50

Enter a value to check within the range: 5

Enter a value to check within the range: 10

Enter a value to check within the range: -1

There are 15 total values that are divisible by the numbers in the range.

Example Execution #2:

Enter the low range value: 335

Enter the high range value: 475

Enter a value to check within the range: 17

Enter a value to check within the range: -1

There are 8 total values that are divisible by the numbers in the range.

Example Execution #3:

Enter the low range value: 100

Enter the high range value: 175

Enter a value to check within the range: 10

Enter a value to check within the range: 2

Enter a value to check within the range: 19

Enter a value to check within the range: -1

There are 50 total values that are divisible by the numbers in the range.

Example Execution #4 (demonstrates input validation requirements):

Enter the low range value: -4

Error! Positive values only!!

Enter the low range value: 3

Enter the high range value: 2

Error! The high range value must be greater than the low range value!

Enter the high range value: 10

Enter a value to check within the range: 0

Error! Enter a positive integer value!

Enter a value to check within the range: -5

Error! Enter a positive integer value!

Enter a value to check within the range: 10

Enter a value to check within the range: 1

Enter a value to check within the range: 2

Enter a value to check within the range: -1

There are 13 total values that are divisible by the numbers in the range.


I GOT EVERYTHING EXCEPT ****EXAMPLE 2****


This is my code


#include<stdio.h>

#include<math.h>

// Function Declaration

int getlow();

int gethigh(int);

int getvalue(int, int);

int main (void)

{

int low = getlow();

int high = gethigh(low);

int final = getvalue(high, low);

//int final = result + getvalue(high, low);

printf(" There are %d total values that are divisible by the number in the range ", final);

return (0);

} //main

int getlow()//this is to get the lower integer and which does not take negative values

{

int low;

do

{

printf("Enter the low range value: ");

scanf("%d", &low);

if (low < 0)

{

printf("Error! Positive values only! ");

}

}while(low < 0);

return(low);

} // getlow

int gethigh(int low)//it takes the low value as parameter and asks

Explanation / Answer

Try this logic:, it fetches the count..


int getvalue(int high, int low)

{

int value,count=0;

do

{

printf("Enter the value to check within the range: ");

scanf("%d", &value);

if (value == 0)

{

printf("Error! Positive value only! ");

}

if (value < -1)

{

printf("Error! Positive value only! ");

}

if(value > 0)

{

if( value < low )

{

for(int i=low;i<=high;i++)

{

if( (i%value) == 0 )

count++;

}

}

if( value > = low )

{

for(int i=value;i<=high;i++)

{

if( (i%value) == 0 )

count++;

}

}

}while (value != -1);

return(count);

} //getvalue

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote