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

Design a C program that displays the number of prime numbers for any number betw

ID: 3806708 • Letter: D

Question


Design a C program that displays the number of prime numbers for any number between 1 and 1000. .oooo AT&T; LTE 7:36 AM 100% K Weekly Assignments Homework 5 Detail Submission Grade Create a C program that performs the following tasks: 1. Prompt the user for a number between 1 and 100 A. Verify the entered number is within the specified range Note: Use the function, bool withinRange(int value, int min, int max). 2. If, and only if the entered number is within the specified range A. Count the number of prime numbers that exist between 0 and the entered number 1. Use the function int Previous Courses Calendar To Do Notifications Messages

Explanation / Answer

#include <stdio.h>
int main()
{
int start, end, x, flag;
printf("Enter two numbers(intervals): ");
scanf("%d %d", &start, &end);

printf("Prime numbers between %d and %d are: ", start, end);

while (start < end)
{
flag = 0;

for(x = 2; x <= start/2; ++x)
{
if(start % x == 0)
{
flag = 1;
break;
}
}

if (flag == 0)
printf("%d ", start);

++start;
}

return 0;
}