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 will be the output of following program #include main() { int x,y = 10; x = y * NULL; printf("%d",x); }
Why structure is used in c?
What are pointers? What are stacks and queues?
how do you redirect stdout value from a program to a file?
Which command is more efficient? *(ptr+1) or ptr[1]
How we add our function in liabrary as liabrary function. Exp. we want use our int factorical(int); function as int pow(int,int); function working in math header file.
Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the college. 1.write a function to print names of all students who joined in a particular year 2.write a function to print the data of a student whose roll number is given
Give the output for the following program. #define STYLE1 char main() { typedef char STYLE2; STYLE1 x; STYLE2 y; clrscr(); x=255; y=255; printf("%d %d\n",x,y); }
4) Write a program that takes a 5 digit number and calculates 2 power that number and prints it.
What does s c mean in text?
What is the use of keyword VOLATILE in C?
Is swift based on c?