logo

Crowdly

There are two statements associated with loops - break and continue. When a bre...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

There are two statements associated with

loops - break and continue. When a break

is encountered inside a loop, program control is transferred outside of it. So,

you use a break within a loop when you want to stop the loop execution at that

instant.

For instance, let’s

suppose you want to find out and print the first occurring multiple of 19

between two given numbers n1 and n2. Here’s what you will do:

int found = 0;  /* a flag to indicate whether multiple found

or not */

for (i=n1; i<=n2; ++i)

  if (i % 19 == 0){

        found=1;    /* setting flag to 1 */

        break;      /* multiple of 19 found; don’t look further */

  }

  if (found)

   printf("%d is the first multiple of 19 between %d and %d.\n", i, n1, n2);

 else 

printf("There is no multiple of 19 between %d and %d.\n", n1,n2);

Now, with this

information, write a C program to find out and print if a given number is prime

or not. Incorporate an input validation check to make sure that the input is

valid.

More questions like this

Want instant access to all verified answers on dle.plaksha.edu.in?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!