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 2c dna?
is it possible to create your own header files?
If fflush wont work, what can I use to flush input?
What does the file stdio.h contain?
1.int a=10; 2.int b=20; 3. //write here 4.b=30; Write code at line 3 so that when the value of b is changed variable a should automatically change with same value as b. 5.
What is the acronym for ansi?
What do you mean by scope of a variable in c?
What is a stream in c programming?
What are local static variables? How can you use them?
if a is an integer variable, a=5/2; will return a value a) 2.5 b) 3 c) 2 d) 0
How can I prevent another program from modifying part of a file that I am modifying?
What is new line escape sequence?
What is c language & why it is used?
What is a function in c?
Describe the order of precedence with regards to operators in C.