-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring9.c
More file actions
29 lines (28 loc) · 751 Bytes
/
string9.c
File metadata and controls
29 lines (28 loc) · 751 Bytes
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
// Check if a given characters is present in string or not.
#include<stdio.h>
#include<string.h>
void charCheck(char str[]);
int main()
{
char str[100];
printf("Enter your string : ");
fgets(str,100,stdin);
charCheck(str);
return 0;
}
void charCheck(char str[])
{
char ch;
int count=0;
printf("This program uses case sensitivity while checking characters \n");
printf("Enter the charcter to check their presence in string : ");
scanf("%c",&ch);
for(int i=0;str[i]!='\0';i++)
{
if(str[i]==ch)
{
count++;
}
}
count==0? printf("%c is not present in the input string \n",ch) : printf("%c is present in the string with %d occurrence \n",ch,count);
}