Monday, 23 January 2017

Write a program to input two number and check whether its is twin prime number or not? Explanation :

Q1.  Write a program to input two number and check whether its is twin prime number or not?

Explanation :

Twin Prime Number C Language Program

Solution :

/*   ################################
     Girfa Student Help
     Twisted Prime number
     for more visit : http://girfahelp.blogspot.in/p/c-language-assignment.html
     ################################
*/
#include<stdio.h>
#include<conio.h>
void main()
{
     int n1,n2,b;
     clrscr();
     printf("Enter Two Number>> ");
     scanf("%d%d",&n1,&n2);
     if(n2-n1==2)
     {
           /* checking n1 and n2 that prime or not */
           for(b=2;b<n1;b++)
           {
                if(n1%b==0)
                     break;
           }
           if(b==n1)
           {
                for(b=2;b<n2;b++)
                {
                     if(n2%b==0)
                           break;
                }
                if(b==n2)
                     printf("\n\tGiven numbers are twisted  Prime");
                else
                     printf("Number is not Twisted Prime");
           }
           else
                printf("\nNumber is not Twisted Prime");
     }
     else
           printf("Input is not Twist Prime Number");
     getch();
}



No comments:

Post a Comment