write a program to count the number the same
(letter/character foreg: 's') in a given sentence.

Answers were Sorted based on User's Feedback



write a program to count the number the same (letter/character foreg: 's') in a given sen..

Answer / vignesh1988i

#include<stdio.h>
#include<conio.h>
void main()
{
char a[100],n;
int count=0;
printf("enter the string");
gets(a);
printf("enter the letter to be searched");
scanf("%c",&n);
for(int i=0;a[i]!='\0';i++)
{
if(a[i]==n)
{
count++;
}
}
printf("so the number of occurances of the given %c
is ",count);
getch();
}

Is This Answer Correct ?    12 Yes 9 No

write a program to count the number the same (letter/character foreg: 's') in a given sen..

Answer / sankara subramanian.n

#include<stdio.h>
#include<conio.h>
void main()
{
char a[100];
int i,count=1;
clrscr();
printf("Enter the string:");
gets(a);
for(i=0;a[i]!='\0';i++)
{
count++;
}
getch();
}

Is This Answer Correct ?    0 Yes 9 No

Post New Answer

More C Code Interview Questions

write a program to Insert in a sorted list

4 Answers   Microsoft,


write a origram swaoing valu without 3rd variable

2 Answers  


What is the main difference between STRUCTURE and UNION?

13 Answers   HCL,


Write, efficient code for extracting unique elements from a sorted list of array. e.g. (1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9) -> (1, 3, 5, 9).

13 Answers   Intel, Microsoft, TCS,


void ( * abc( int, void ( *def) () ) ) ();

1 Answers  






main() { int a=2,*f1,*f2; f1=f2=&a; *f2+=*f2+=a+=2.5; printf("\n%d %d %d",a,*f1,*f2); }

6 Answers  


how can i cast a char type array to an int type array

2 Answers  


how to return a multiple value from a function?

5 Answers   Wipro,


write a c program to Reverse a given string using string function and also without string function

1 Answers  


main(){ char a[100]; a[0]='a';a[1]]='b';a[2]='c';a[4]='d'; abc(a); } abc(char a[]){ a++; printf("%c",*a); a++; printf("%c",*a); }

2 Answers  


void func1(int (*a)[10]) { printf("Ok it works"); } void func2(int a[][10]) { printf("Will this work?"); } main() { int a[10][10]; func1(a); func2(a); } a. Ok it works b. Will this work? c. Ok it worksWill this work? d. None of the above

1 Answers   HCL,


Given an array of characters which form a sentence of words, give an efficient algorithm to reverse the order of the words (not characters) in it.

2 Answers   Wipro,


Categories