The Codeclub, SMVDU
Strings
Questions based on strings
In computer programming, a String is a sequence of characters.
or
A string is nothing but a character array.
A string is stored in an array of type char ending with the null character '\0 '
while(1){
scanf("%c",&a[i]);
if(a[i]=='\0'){
break;}
i++;
}
To scan:
char name[10];
scanf("%s",name );
To print:
printf("%s", name );
Write a program to take a string from user as input and print that string.
Write a program to find the length of a string.
Write a program to calculate the frequency of a character in a string. ( Take character from user)
sample input: i mritunjayvamsi
sample output: Frequency of i is : 2
Write a program to calculate no. of vowels and consonants in a string.
sample input:
programmer
sample output:
No of vowels: 3
No of consonants: 7