C program to find blank spaces in a string or sentence.
We will write a simple c program source code to find white space in a string.
White Spaces as:- " "
Here we will use string header file to create a program code to find number of white spaces in a string or sentence.
In the first user enter a string then the compiler print the number of blank spaces.
We will write a simple c program source code to find white space in a string.
White Spaces as:- " "
Here we will use string header file to create a program code to find number of white spaces in a string or sentence.
In the first user enter a string then the compiler print the number of blank spaces.
C program code
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int x,spaces=0;
char str[200];
clrscr();
printf("\n ENTER A STRING OR SENTENCE TO FIND THE NUMBER OF WHITE SPACES:\n ");
gets(str);
for(x=0;x<strlen(str);x++)
{
if(str[x]==' ')
{
spaces++;
}
}
printf("\n NUMBER OF WHITE SPACES IN THIS STRING IS:\n ");
printf("%d\n",spaces);
getch();
}
OUTPUT:
Please share this post and blog link with your friends.For more programs use this blog.
If you have any problem, please comment in comment box, subscribe this blog for notifications of new post on your email and follow this blog.If you have any method of this program or want to give any suggestion send email on hc78326@gmail.com
Created by-- HARSH CHAUHAN
No comments:
Post a Comment