Professional Documents
Culture Documents
For example 34 can be expressed as sum of two prime numbers but 23 cannot be.
program::
for(int i=2;i<=n/2;i++){
if(n%i==0){
return false;
}
}
return true;
int n=66;
int flag=0;
for(int k=2;k<=n/2;k++){
if(prime(k)==true){
if(prime(n-k)==true){
flag=1;
System.out.println();
}
}
}
if(flag==0)
Input : n = 32
Output : 55
23 + 32 = 55 which is a palindrome.
Input : 39
Output : 363
program::
int temp=k,re=0,sum=0;
while(temp>0){
re=temp%10;
sum=sum*10+re;
temp/=10;
return sum;
int temp=0,re=0,sum=0,n=39,flag=0;
for(int i=1;i<=5;i++){
int reve=reverse(n);
n=n+reve;
int m=reverse(n);
if(n==m){
System.out.print(" no is"+n);
flag =1;
break;
if(flag==0){
}
}
Question 3:Given a string, reverse only vowels in it; leaving rest of the string as
it is.
Input : abcdef
Output : ebcdaf
program:
if(c=='A'||c=='E'||c=='I'||c=='O'||c=='U'||c=='a'||c=='e'||c=='i'||c=='o'||
c=='u')
return true;
return false;
char a[]=s.toCharArray();
int i=0;
int j=a.length-1;
while(i<j){
if(!isvowel(a[i])){
i++;
}
if(!isvowel(a[j])){
j--;
}
else
{
if(i<j){
char c=a[j];
a[j]=a[i];
a[i]=c;
i++;
j--;
for(char aa:a)
System.out.print(aa);
}
}