Program in C to find prime numbers in a given 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;
}
import java.util.*;
public class prac2{
    public static void main(String[] args){
  /* Ask user to input the from/to range
    like 1 to 100, 10 to 1000 etc.
  */
        System.out.println("Enter two range(input integer numbers only):");
        Scanner sc=new Scanner(System.in);
        int num1=sc.nextInt();
        int num2=sc.nextInt();
        //Store the range in variables using scanf.
        //Display prime numbers for input range.
        System.out.println("Prime numbers from :"+ num1+ num2);
        for(int i=num1+1; i<num2; ++i)
        {
            int flag_var=0;
            for(int j=2; j<=i/2; ++j)
            {
                if(i%j==0)
                {
                    flag_var=1;
                    break;
                }
            }
            if(flag_var==0)
                System.out.println(i);
        }
    }
}

OUTPUT

Enter two range(input integer numbers only):Prime numbers from 1 and 50 are: 1 50
2
3
5
7
11
13
17
19
23
29
31
37
41
43
47