pgm to find number of words starting with capital letters
in a file(additional memory usage not allowed)(if a word
starting with capital also next letter in word is capital
cann't be counted twice)
Answers were Sorted based on User's Feedback
Answer / vadivelt
I havent write the code to read the no of words starts with
capital letter for a file. But for normal sentence given as
input.
#include<stdio.h>
#include<conio.h>
int main()
{
char *ptr;
int count = 0;
ptr = (char *)malloc(200);
printf("ENTER THE SENTENCE\n");
ptr = gets(ptr);
while(*ptr != '\0')
{
/*This condition is used for the first word
in the sentence*/
if(count == 0 && (*ptr >=65 && *ptr <= 90))
{
count++;
}
else if(*(ptr-1) == ' ' && (*ptr >=65 &&
*ptr <= 90))
{
count++;
}
ptr++;
}
printf("\nNO OF WORDS STARTS WITH CAPITAL LETTER
IS: %d\n", count);
getch();
}
| Is This Answer Correct ? | 7 Yes | 1 No |
What is include directive in c?
Explain what is the difference between a string and an array?
what are the interview question's in the language c
Is exit(status) truly equivalent to returning the same status from main?
what is constant pointer?
What do you mean by c?
read a number & print all its devisors using c-program?
What is the use of a conditional inclusion statement in C?
#define FALSE -1 #define TRUE 1 #define NULL 0 main() { if(NULL) puts("NULL"); else if(FALSE) puts("TRUE"); else puts("FALSE"); }
What is difference between structure and union?
What are pointers? What are stacks and queues?
What is void main ()?