Write a program to display the characters in prime position of a given string.
Sample InputComputer
Sample Output
o m u e
#include<stdio.h>
#include<string.h>
int main() {
char str[50];
int i, j;
fgets(str,50,stdin);
for(i=2;i<=strlen(str);i++){
for(j=2;j<=i/2;j++){
if(i%j==0){
break;
}
}
if(j>i/2)
printf("%c ",str[i-1]);
}
return 0;
}
#include<string.h>
int main() {
char str[50];
int i, j;
fgets(str,50,stdin);
for(i=2;i<=strlen(str);i++){
for(j=2;j<=i/2;j++){
if(i%j==0){
break;
}
}
if(j>i/2)
printf("%c ",str[i-1]);
}
return 0;
}