Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit e0e7bf9

Browse files
solve 8th problem of string in C
1 parent 83c764d commit e0e7bf9

File tree

2 files changed

+39
-14
lines changed

2 files changed

+39
-14
lines changed

‎a.out‎

-8 Bytes
Binary file not shown.

‎solve_problem.c‎

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -156,26 +156,51 @@
156156
// }
157157

158158
// // 👉👉 🔹🔹 question 7️⃣ write a function to count occurrence of vowels in a string
159+
160+
// #include <stdio.h>
161+
// int countVowels(char str[]);
162+
// int main()
163+
// {
164+
// char str [] = "Education";
165+
// printf("Vowel are : %d\n" , countVowels(str)); // Function call ;
166+
// return 0;
167+
// }
168+
// // Function Definition
169+
// int countVowels(char str[])
170+
// {
171+
// int count = 0;
172+
// for (int i = 0; str[i] != '0円'; i++)
173+
// {
174+
// if (str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u')
175+
// {
176+
// count ++;
177+
// }
178+
// }
179+
// return count ;
180+
// }
181+
182+
// // 👉👉 🔹🔹question 8️⃣ check a given Character is present in a string or not
159183
#include <stdio.h>
160-
intcountVowels(char str[]);
161-
int main()
162-
{
163-
char str [] ="Education";
164-
printf("Vowel are : %d\n" , countVowels(str)); // Function call ;
184+
voidcheckStr(char str [] , charch ) ;
185+
int main(){
186+
charstr [] ="Coder Boy ";
187+
char ch='B';
188+
checkStr(str , ch);
165189
return 0;
166190
}
167-
// Function Definition
168-
int countVowels(char str[])
169-
{
170-
int count = 0;
191+
void checkStr(char str [] , char ch ) {
171192
for (int i = 0; str[i] != '0円'; i++)
172193
{
173-
if (str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u')
174-
{
175-
count ++;
176-
}
194+
if (str[i] == ch)
195+
{
196+
printf("Character is present \n");
197+
return ;
198+
}
199+
177200
}
178-
return count ;
201+
printf("Character is Not present \n");
202+
203+
179204
}
180205

181206
// 1️⃣ 2️⃣ 3️⃣ 4️⃣ 5️⃣ 6️⃣ 7️⃣ 8️⃣ 9️⃣ 🔟

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /