Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
Untitled
SUBMITTED BY:
antoineh1
DATE:
June 3, 2016, 12:49 p.m.
FORMAT:
Text only
SIZE:
813 Bytes
Raw
Download
Tweet
HITS:
517
Go to comments
Report
#include <stdio.h>
#include <string.h>
int main(){
char name[25];
int numname = 0;
char *ret;
printf("Enter a series of names and type 'end' to stop:\n");
do
{
scanf("%[^\n]", name );
getchar();
ret = strchr(name,' ');
while (strlen(name) > 25 || ret != NULL) //Check if the name exceeds 25 characters.
{
printf("Name must not exceed 25 characters or contain blank characters:\n");
printf("Enter a name again: \n");
scanf("%[^\n]", name );
getchar();
ret = strchr(name,' ');
}
if (strlen(name) > 10) //Check if the name is more than 10 characters and count it.
numname++;
}
while (strcmp(name,"end") != 0); //If name is 'end' then stop the program.
printf("The number of names containing more than 10 characters is %d.",numname);
return 0;
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus