forked from yash28goyal/C
-
Notifications
You must be signed in to change notification settings - Fork 0
/
counting_array.c
52 lines (41 loc) · 1.06 KB
/
counting_array.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include<stdio.h>
#include<string.h>
void vowel(char newStr[], int n);
void finder(char old[], char P, int A);
int main(){
// Counting Vowel.
char string[100];
printf("Enter your string in lower alphabets: ");
// scanf("%s", string);
fgets(string,100,stdin);
int len = strlen(string);
vowel(string, len);
// finding a character.
char str;
printf("\nInput your charcter: ");
scanf("%c",&str);
finder(string, str, len);
return 0;
}
void vowel(char newStr[], int n){
int count = 0;
for (int i = 0; i < n; i++)
{
if (newStr[i] == 'a' || newStr[i] == 'e' || newStr[i] == 'i'|| newStr[i] == 'o'|| newStr[i] == 'u')
{
count++;
}
}
printf("Your total vowel in the given string is: %d", count);
}
void finder(char old[], char P, int A){
int Res = 0;
for (int i = 0; i < A; i++)
{
if (old[i] == P)
{
Res++;
}
}
printf("\nYour entered character is present %d times in the string.", Res);
}