C program to print the initial character of any stringThere we will see the c program which is print the initial character of each string. In which we use the character array.
For Example:
if we take input from user: "C Programming Simply"
there is three string value and the Initial character of each string is CPS
ALGORITHM:-
step 1 : Start
step 2 : Take an character array
step 3 : Take the input from user
step 4 : While(string[i]!='\0')
step 5 : If [i]th value is ' '(space) then the print the i+1 character
step 6 : Exit
PROGRAM CODE:-
#include<stdio.h>
#include<stdio.h>
int main()
{
char str[20];
int i=0;
printf("Enter a string: ");
gets(str);
printf("%c", *str);
while(str[i] != '\0')
{
if(str[i] == ' ')
{
i++;
printf("%c", *(str + i));
}
i++;
}
return 0;
}
OUTPUT:-
Enter a string:
C Programming Simply
CPS
C program to print the initial character of any string print the initial character value in a given string using c Starting character of any string
ConversionConversion EmoticonEmoticon