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 the c source code for the below output? 5555555555 4444 4444 333 333 22 22 1 1 22 22 333 333 4444 4444 5555555555
PLS U SENS ME INTERVIEW O. MY EMAIL ADD, SOFIYA.SINGH@GMAIL.COM
Can we declare a function inside a function in c?
Explain do array subscripts always start with zero?
What is the total generic pointer type?
What are the ways to a null pointer can use in c programming language?
What is page thrashing?
Explain the difference between malloc() and calloc() in c?
What would happen to X in this expression: X += 15; (assuming the value of X is 5)
What is variable declaration and definition in c?
What is logical error?
What is a stream?
How to write a code for reverse of string without using string functions?
What does the && operator do in a program code?
What is adt in c programming?