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 difference between array of characters and string
Program to trim a given character from a string.
What is a macro in c preprocessor?
explain memory layout of a C program
Can a variable be both constant and volatile?
If 4 digits number is input through the keyboard, Write a program to calculate sum of its 1st & 4th digit.
when will be evaluated as true/ if(x==x==x) a) x=1; b) x=0; c) x=-1; d) none
Does c have circular shift operators?
Sir i want e-notes of C languge of BAlaguruswami book i.e scanned or pdf file of balaguruswamy book on c language.PLEASE SEND ME on my mail id ajit_kolhe@rediff.com
How can I increase the allowable number of simultaneously open files?
What is c language used for?
What does the characters “r” and “w” mean when writing programs that will make use of files?