write a program to input a name & print how many times alphabet C appears in that name in java programming
Answers
Answered by
1
HERE IS A C PROGRAM
__________________________________
#include <stdio.h>
#include <string.h>
int main()
{
char string[100];
int c = 0, count
[26] = {0}, x;
printf("Enter a string\n");
gets(string); while (string[c] != '\0')
{
/** Considering characters from 'a' to 'z' only and ignoring others. */
if (string[c] >= 'a' && string[c] <= 'z') { x = string[c] - 'a'; count[x]++;
}
c++;
}
for
(c = 0; c < 26; c++)
printf
("%c occurs %d times in the string.\n", c + 'a', count[c]);
return 0
; }
__________________________________
#include <stdio.h>
#include <string.h>
int main()
{
char string[100];
int c = 0, count
[26] = {0}, x;
printf("Enter a string\n");
gets(string); while (string[c] != '\0')
{
/** Considering characters from 'a' to 'z' only and ignoring others. */
if (string[c] >= 'a' && string[c] <= 'z') { x = string[c] - 'a'; count[x]++;
}
c++;
}
for
(c = 0; c < 26; c++)
printf
("%c occurs %d times in the string.\n", c + 'a', count[c]);
return 0
; }
Similar questions