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 will you allocate memory to double a pointer?

1 Answers  


The postoder traversal is 7,14,3,55,22,5,17 Then ur Inorder traversal is??? please help me on this

1 Answers  


Why doesnt the call scanf work?

0 Answers  


What is the size of enum in bytes?

0 Answers  


Write a program to print this triangle: * ** * **** * ****** * ******** * ********** Don't use printf statements;use two nested loops instead. you will have to use braces around the body of the outer loop if it contains multiple statements.

6 Answers   Wipro,






what is uses of .net

0 Answers  


# define prod(a,b)=a*b main() { int x=2; int y=3; printf("%d",prod(x+2,y-10)); } the output of the program is a.8 b.6 c.7 d.none

7 Answers   Microsoft, TCS,


What is the use of #include in c?

0 Answers  


What does 2n 4c mean?

0 Answers  


How can type-insensitive macros be created?

0 Answers  


What is the function of multilevel pointer in c?

0 Answers  


What are pragmas and what are they good for?

0 Answers  


Categories