Count Words in CamelCase String
Duration: 4 min
This video lesson is available to enrolled students.
Inside: a video lesson and guided study material.
Module outline
- TCS One Shot Free Videos & Notes: TCS Preparation
- Numerical Ability (Foundation Section): Ratio and Proportion (Ratios), Divisibility Rules, Data Interpretation, Mixture and Alligation, Permutation and Combination, Logarithm, Number System, HCF LCM, Sequence and Series (Series), Speed Time and Distance, Percentage, Average, Powers and Exponents (Surds and Indices), Algebra, Probability, Profit and Loss, Simple Interest and Compound Interest, Time and Work, Pipe and Cistern, Mensuration and Geometry, Mental Ability, Age Problems, Statistics, Arithmetic, Partnership, Speed Mathematics and Basic Mathematics
- Reasoning Ability (Foundation Section): Series (Number and Letter Series) (Numerical Relations and Reasoning), Coding Decoding, Data Sufficiency, Non Verbal Reasoning (Spatial Aptitude) (Spatial Reasoning) (Visual Reasoning), Syllogisms, Deductive and Inductive Reasoning (Logical Deduction and Induction) (Prepositional Reasoning), Seating Arrangements, Blood Relations, Directions (Direction Test), Analytical Reasoning (Counting Figures Reasoning), Puzzle Solving (Puzzles), Calendar, Clock, Cubes & Dices, Selection Decision Table (Decision Making), Crypt Arithmetic, Venn Diagram, Data Arrangement, Inequality, Analogy, Ranking, Order and Sequence, Logical Sequence Of Words
- New Pattern-Verbal Ability (Foundation Section): Sentence Completion (Fill in the blanks), English Writing Ability
- Old Pattern-Verbal Ability (Foundation Section): Vocabulary, Noun, Subject Verb Agreement (Verb Noun Agreement), Adjectives, Tenses, Pronoun, Preposition, Articles, Direct and Indirect Speech, Conjunction, Modals, Sentence Re-arrangements (Para Jumbles) (Narrative Sequencing), Sentence Correction (Error Correction), Comprehension / Reading Comprehension / Unseen Passages (Critical Reasoning) (Paragraph Questions), Verbal Analogy (Word Based Analogy), Active Passive Voice (Voice), Determiner, Facts, Inference and Judgements, Adverb, Cloze Test (Cloze Passage), Sentence Construction, Verb
- Advanced Quantitative Ability: TCS NQT Advanced Quantitative Ability
- Advanced Reasoning Ability: TCS NQT Advanced Reasoning Ability
- Advanced Coding: Coding Questions by Yash Sir, C Programming by Yash Sir, Python for Placements by Yash Sir, DSA using Python, Object Oriented Programming (OOPS), Programming in C++, Java
- TCS Full Length Mock Test:
- TCS Interview & Resume Prep: MR & HR Interview Preparation, TCS Interview Preparation, Mock Interview, Interview Recordings, Resume Preparation, Resume Review
- Mega Test:
- Grand Test:
AI summary & chapters
AI Summary
An AI-generated summary of this video lecture.
This video is a programming tutorial from Knowledge Gate that teaches how to count words in a string based on specific capitalization rules. The instructor first presents a problem where the first word is entirely lowercase, and all subsequent words start with an uppercase letter followed by lowercase letters. The task is to count the total number of words in the string. The solution involves iterating through the string and identifying word boundaries by checking for uppercase letters. The instructor then demonstrates the solution in C, using a for loop and an if condition to check if a character is an uppercase letter (ASCII 65-90). The code is implemented and tested in an online C compiler, where the input "saveChangesInTheEditor" correctly outputs 5 words, and another test case "iAmShubam" outputs 3 words. The video concludes with a discussion on the logic and a final code run.
Chapters
0:00 – 2:00 00:00-02:00
The video begins with the Knowledge Gate logo, followed by a slide detailing a programming problem. The problem states that a sequence of words is written with the first word in lowercase and all subsequent words starting with an uppercase letter and the rest in lowercase. The task is to count the number of words in a given string. The input is a single line of text, and the output is the word count. The constraints specify the string length is between 1 and 10^5. An example is provided: the input "saveChangesInTheEditor" should output 5, and "iAmShubam" should output 3. The instructor, Yash Jain Sir, explains the problem, emphasizing that the first word is all lowercase and each subsequent word starts with an uppercase letter. He uses a red pen to circle the first word and the uppercase letters in the subsequent words, visually reinforcing the rule. He then explains that the solution involves counting the number of uppercase letters, which indicates the start of a new word, and adding one for the first word.
2:00 – 3:38 02:00-03:38
The instructor transitions to coding the solution in C. The code is displayed on a screen, showing the inclusion of string.h and stdio.h, and the main function. A character array `st[10000]` is declared to hold the input string, and an integer `cnt` is initialized to 0. The `scanf` function reads the input string. A for loop iterates through the string using `strlen(st)`. Inside the loop, an if condition checks if the current character `st[i]` is an uppercase letter by verifying if its ASCII value is between 65 and 90. If true, the counter `cnt` is incremented. After the loop, `printf("%d", cnt+1);` is used to print the total word count, which is the number of uppercase letters plus one for the first word. The instructor explains this logic, highlighting the `cnt` variable and the `printf` statement. The code is then run in an online C compiler. The input "saveChangesInTheEditor" is entered, and the output is 5. The instructor then tests another input, "iAmShubam", which correctly outputs 3, confirming the solution works.
The video provides a clear, step-by-step tutorial on solving a word counting problem with specific capitalization rules. It starts with a well-defined problem statement, uses visual aids to explain the pattern, and then implements a logical solution in C. The core concept is that the number of words is equal to the number of uppercase letters (indicating new words) plus one for the initial lowercase word. The demonstration in the online compiler validates the solution, making it a practical and effective learning resource.

