Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...

write a c program that if the given number is prime, and
their rearrangement(permute) of that number is also prime.
Ex: Input is "197" is prime
Output: 791,917,179 is also prime.
Please any one tell me tha code for that

Answers were Sorted based on User's Feedback

write a c program that if the given number is prime, and their rearrangement(permute) of that numb..

hello Sir,

If you dont mind, could you exlain that above code

 Is This Answer Correct ? 0 Yes 0 No

write a c program that if the given number is prime, and their rearrangement(permute) of that numb..

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
static boolean permutablePrime(int n)
{
String str=String.valueOf(n);
int len=str.length();
for(int i=0;i<len;i++)
{
String str1=str.substring(0,i);
String str2=str.substring(i,len);
String str3=str2.concat(str1);
//System.out.println(str3);

if(!isPrime(Integer.parseInt(str3)))
{
return false;
}
}
return true;
}
static boolean isPrime(int n)
{

for(int i=2;i<n/2;i++)
{
if(n%2==0)
{
return false;
}
}
return true;
}
public static void main (String[] args)
{
if(isPrime(193))
{
if(permutablePrime(193))
{
System.out.println("permutable prime");
}
else
System.out.println("Not permutable prime");
}
else
{
System.out.println("Not permutable prime");
}
}
}

 Is This Answer Correct ? 0 Yes 0 No

write a c program that if the given number is prime, and their rearrangement(permute) of that numb..

#include<stdio.h>
#include<conio.h>
void main()
{
int a;
printf("197 is prime");
if a%2 || a%3||a%5||a%7
getch();
}

 Is This Answer Correct ? 1 Yes 5 No

More C Interview Questions

What will happen when freeing memory twice

What is #error and use of it?

main() {int a=200*200/100; printf("%d",a); }

Draw a diagram showing how the operating system relates to users, application programs, and the computer hardware ?

what is the different between if-else and switch statment (other than syntax)

What is the difference between big endian form and little endian form? write a code to convert big endian form to little endian and vice versa..

Illustrate it   summing the series 2+4+6+......to n terms using  (i) while loop (ii) do-while loop

What is string function c?

Without using main fn and semicolon,print remainder for a given number in C language

list the no of files created when c source file is compiled

What is false about the following A compound statement is a.A set of simple statments b.Demarcated on either side by curly brackets c.Can be used in place of simple statement d.A C function is not a compound statement.

Categories
• C (4646)
• C++ (3462)
• VC++ (653)
• Delphi (566)
• Python Related (3238)
• PHP Related (7341)
• Scala (340)
• R Programming (396)
• Kotlin (184)
• Apache Groovy (39)
• Ruby (245)
• Go Programming Language (139)
• Objective-C (429)
• Programming Languages AllOther (736)