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)
Answer Posted / 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 |
Post New Answer View All Answers
What is character set?
What are the functions to open and close file in c language?
Explain why can’t constant values be used to define an array’s initial size?
Are comments included during the compilation stage and placed in the EXE file as well?
How do you define a function?
What is the use of typedef in c?
How to explain the final year project as a fresher please answer with sample project
What is #include stdio h?
What is the -> in c?
In the DOS enveronment, normal RAM that resides beyond the 1mb mark. a) expanded memory b) swapped memory c) Extended memory d) none
What is bubble sort technique in c?
When c language was developed?
Explain high-order and low-order bytes.
Explain enumerated types.
Is using exit() the same as using return?