Write a program main method that prompts the user for a doub
Write a program (main method) that prompts the user for a \"doubled\" String, where every character is immediately duplicated. It prints the un-doubled version. Include a loop so that the user is repeatedly prompted.
Solution
//C Programme
#include <stdio.h>
int main(void)
{
char str[100];
char ch;
int i=0,k,x=0;
printf(\"Enter Doubled vertion String (Example : aabbccdd)\ \") ;
while((str[i] = getchar())!=\'\ \') //loop to read string untill center char
{
i++;
}
printf(\"Single vertion String \ \") ;
for(k=0;k<=i;k=k+2) //loop to dispaly single vertion
{
printf(\"%c\",str[k]);
}
return 0;
}
Output :
Enter Doubled vertion String (Example : aabbccdd)
aabbccddee
Single vertion String
abcde