Is Prime - Easy Problems - Solution to Toph.co Online Judge Problem

Is Prime

Limits 1s, 512 MB

Given an integer N, determine if it is a prime a number.
A number is called prime if it is only divisible by itself.

Input

The input will contain one integer N (0 < N < 1000).

Output

Print “Yes” if the integer is prime, otherwise “No”.

#include<stdio.h>

int main()
{
  int n,flag=0,i=2;

  scanf("%d",&n);

  while(i<n)
  {
      if(n%i==0)
      {
          flag=1;
          break;
      }
     i++;

  }

  if(flag==0)
    printf("Yes\n");
  else
    printf("No\n");

    return 0;

}