adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

Write a program in C to count the entered character in given string.

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:



  1.     Write a program in C to read multiple string and then print.
  2.     Write a program in C to find the number of characters in given string using pointer.
  3.     Write a program in C to covert small letter to capital letter.
  4.     Write a program in C to covert  capital letter to small letter.
  5.     Write a program in C to print month in word.
  6.     Write a program in C to find the number of characters in given string.

Post a Comment

0 Comments