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


Please Help Members By Posting Answers For Below Questions

What is 2c dna?

611


is it possible to create your own header files?

646


If fflush wont work, what can I use to flush input?

618


What does the file stdio.h contain?

608


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.

1666






What is the acronym for ansi?

634


What do you mean by scope of a variable in c?

546


What is a stream in c programming?

598


What are local static variables? How can you use them?

649


if a is an integer variable, a=5/2; will return a value a) 2.5 b) 3 c) 2 d) 0

1455


How can I prevent another program from modifying part of a file that I am modifying?

618


What is new line escape sequence?

814


What is c language & why it is used?

585


What is a function in c?

577


Describe the order of precedence with regards to operators in C.

635