Wednesday, 19 October 2016

11C- Prog-11 Write a Algorithm and Program to check whether the number is prime or not.

1   

    11. Write a Algorithm and program to check whether the number is prime or not. 

 Input:

1) n 

Output:

1)     n is prime or not

 Method:

1.start

2. Read n

3. Print n

4. //logic of prime

Flag = 0;

for(i=2; i<=n-1; i++)

{    

  If( n % i == 0) 

    {

       Flag=1;

       break;

     }

}

If(Flag==1)

Print “the number is not prime”

else

Print “the number is prime

5.stop 


No comments:

Post a Comment