Write a program in C to count the entered character in given string.
#include<stdio.h> #include<conio.h> #include<string.h> void main() { char str[100],ch; int i,count=0; clrscr(); printf("Enter a string:-"); gets(str); printf("Enter a charater:-"); scanf("%c",&ch); for(i=0;str[i]!='\0';i++) { if(str[i]==ch) count++; } printf("%c is repeated in %s %d time.",ch,str,count); getch(); }
Output:
- Write a program in C to read multiple string and then print.
- Write a program in C to find the number of characters in given string using pointer.
- Write a program in C to covert small letter to capital letter.
- Write a program in C to covert capital letter to small letter.
- Write a program in C to print month in word.
- Write a program in C to find the number of characters in given string.
0 Comments