-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path9.c
More file actions
34 lines (27 loc) · 707 Bytes
/
9.c
File metadata and controls
34 lines (27 loc) · 707 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
30
31
32
33
34
/*
Q9.
Write a function to accept a sring and a group of characters to search for in the input string.
Display a message if it exists and the postion in the string. */
#include <stdio.h>
#include <string.h>
int main()
{
char a, word[50];
int i = 0;
printf("Enter character: ");
scanf("%c", &a);
printf("Now enter the word: ");
scanf("%s", word);
for (i = 0; i < strlen(word); i++)
{
if (word[i] == a)
{
printf("Positions of '%c' in %s are: ", a, word);
printf("%d ", i + 1);
}
}
if(strlen(word)!=a){
printf("\n Ops it don't exist");
}
return 0;
}