a c program to computes the prime numbers in the user mentioned range

#include <stdio.h>
int main()
{
   int num1, num2, flag_var, i, j;
 
   /* Ask user to input the from/to range
    * like 1 to 100, 10 to 1000 etc.
    */
   printf("Enter two range(input integer numbers only):");
   //Store the range in variables using scanf
   scanf("%d %d", &num1, &num2);
 
   //Display prime numbers for input range
   printf("Prime numbers from %d and %d are:\n", num1, num2);
   for(i=num1+1; i<num2; ++i)
   {
      flag_var=0;
      for(j=2; j<=i/2; ++j)
      {
         if(i%j==0)
         {
            flag_var=1;
            break;
         }
      }
      if(flag_var==0)
         printf("%d\n",i);
  }
  return 0;
}

Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
write a program to display prime numbers between 1 and 100 using functions in c prime numbers range in c prime numbers in the given range in c Write a program in C to find the prime numbers within a range of numbers. c program to find all the prime numbers in given range prime number in given range in c prime numbers of range in c write a c program to find all prime number between user given range c program to find prime numbers between given range using functions program to find prime number in a range c program to find prime number in a range c prime numbers in a given range in c c program to print co prime number between range print co prime numbers in range in c c program to count prime numbers in a given range using function c program to print prime numbers in a given range using function output will be no. of ans c program to print prime numbers in a given range using function write a c program to print the prime numbers in the given range print all the prime numbers in a given range in c c program to print prime numbers between in agiven range prime number in a range in c efficient prime numbers in a range in c prime numbers in given range in c prime no in range program in c prime numbers in a range c prime number range program in c Write down a C program to find all the prime numbers in a given range (upper and lower range should be given from the keyboard). program to find prime numbers in a given range in c c program to print prime numbers between given range c program to display the prime numbers in a given range c program to find prime number between 1 and 100 how many prime numbers are before a number in c+_+ print prime number in given range c code to print prime numbers within a range printf all super primes in range prime numbers upto range program checking prime numbers in c in a range all prime number in given range c prime number program in c in given range find prime numbers in a given range c find prime rangers between two numbers
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source