Find occurence of a character in a sting.

Answers were Sorted based on User's Feedback



Find occurence of a character in a sting...

Answer / furquan

Use strchr

Is This Answer Correct ?    6 Yes 1 No

Find occurence of a character in a sting...

Answer / anil kumar nahak

void main()
{
char *st,ch;
int i=0,c=0;
printf("\n Enter The String: ");
gets(st);
printf("\n Enter A character For finding occurance: ");
scanf("%c",&ch);

while(st[i]!='\0')
{
if(st[i]==ch)
c++;
i++;
}
printf("\n %c Present In The String %d Times",ch,c);

}

Is This Answer Correct ?    4 Yes 2 No

Find occurence of a character in a sting...

Answer / chanti

strchr()
it is the function which we use in string() while we r
using characters in it.

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More C Interview Questions

How can I increase the allowable number of simultaneously open files?

1 Answers   ABC,


I have an array of 100 elements. Each element contains some text. i want to: append a star character to the end of every fifth element remove every second character from every tenth element, and… add a line feed (ascii 10) after the 30th character of every array element whose length is greater than 30 characters.

1 Answers  


the data type used for unlimited value in c and how to do this program

1 Answers  


What is infinite loop?

0 Answers  


in linking some of os executables are linking name some of them

0 Answers   IBM,






How to find a missed value, if you want to store 100 values in a 99 sized array?

0 Answers   Honeywell, Zomato,


how to TOGGLE Nth bit of variable in a MACRO

1 Answers   NDS,


is assignment operator is arithmatic or not

3 Answers   Infosys,


Explain spaghetti programming?

0 Answers  


write a program to convert a expression in polish notation(postfix) to inline(normal) something like make 723+* (2+3) x 7 (not sure) just check out its mainly printing expression in postfix form to infix.

0 Answers   Subex,


Can we declare a function inside a function in c?

0 Answers  


main() { int a; a=++100; printf("%d",a); getch(); }

4 Answers  


Categories