#include<stdio.h>
#include<stdlib.h>
int main(){
char str1[80]="Hello Student Lets count spaces in this string.";
int i, space_counter=0;
printf("Given String = %s",str1);
for(i=0; i<strlen(str1); i++)
{
if(str1[i] == 32) //32 is ascii value of space
space_counter++;
}
printf("\nTotal space in the given string is %d", space_counter );
return 0;
}
Output of the program:
Given String = Hello Student Lets count spaces in this string.
Total space in the given string is 7
#include<stdlib.h>
int main(){
char str1[80]="Hello Student Lets count spaces in this string.";
int i, space_counter=0;
printf("Given String = %s",str1);
for(i=0; i<strlen(str1); i++)
{
if(str1[i] == 32) //32 is ascii value of space
space_counter++;
}
printf("\nTotal space in the given string is %d", space_counter );
return 0;
}
Output of the program:
Given String = Hello Student Lets count spaces in this string.
Total space in the given string is 7
Nice concepts...
ReplyDeleteThank you.
DeleteThank for your kind Information, keep posting and do post something about Embedded System Programmingalso.
ReplyDelete