#include<stdio.h>
#include<conio.h>
#include<string.h>
char alt(char *p);
void main()
{
char str[10];
clrscr();
printf(" \n \n Enter the string: \t ");
gets(str);
alt(str);
getch();
}
char alt(char *p)
{
int j,l;
l = strlen(p);
printf(" \n \n Alternate characters of the entered string are: \t ");
for(j = 0; j <= l - 1; j = j + 2)
{
printf("%c",p[j]);
}
return 1;
}
OUTPUT:
Enter the string: BODYGUARD
Alternate characters of the entered string are:
B D G A D
ALSO READ:
Sample C Program To Swap Two Strings Using strcpy() Function.
Sample C Program To Sort A Given Number Of Strings Using strcmp() Function.
Sample C Program To Display Array Of Strings.
Sample C Program To Convert String To An Integer Using atoi() Function.
Sample C Program To Find The Length Of A String.
Comments
Post a Comment
Please share your opinions and suggestions or your experience in the comments section. This way we can all help each other...
Experienced guys can share their resumes at admin@interview-made-easy.com