Find Number of Days in a Month
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 write a C program to determine the number of days in a given month. The instructor first presents the problem statement, Q10, which requires a user to input a date in dd-mm-yyyy format and output the number of days in that month, with the instruction to ignore leap years. The solution is broken down into a logical approach: parsing the input string to extract the month, using a predefined array of days for each month, and then outputting the result. The instructor then transitions to writing the code, showing the necessary header files, the main function, and the use of the `strtok` function to split the date string by the '-' delimiter. The code is completed by converting the month string to an integer and using it as an index to access the correct number of days from the array. The video concludes with the final code snippet and a brief explanation of the logic.
Chapters
0:00 – 2:00 00:00-02:00
The video begins with the Knowledge Gate logo, followed by a slide introducing the problem, Q10. The problem statement is clearly displayed: 'User enters date in dd-mm-yyyy find out number of days in month (for now please ignore the concept of leap year)'. The input is specified as a date in dd-mm-yyyy format, and the output is the number of days in that month. Two public test cases are provided: for the date 12-03-2006, the output is 31, and for 31-11-1996, the output is 30. The instructor, Yash Jain Sir, is visible in a small window, and the slide includes a 'Placement Expert' graphic and a copyright notice for Knowledge Gate Eduventures. The instructor begins to explain the problem, emphasizing the need to parse the date string to extract the month.
2:00 – 4:18 02:00-04:18
The instructor transitions to the coding phase, with a 'Code' label appearing on the screen. He begins writing the C program, starting with the necessary header files: #include <stdio.h> and #include <string.h>. He then defines the main function and initializes an integer array `arr` with the number of days for each month, starting from January (index 0). The array is populated as {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}. He then writes the code to take user input using `scanf`, store it in a character array `date[11]`, and use `strtok` to split the string by the '-' delimiter to extract the month. He explains that the month string is then converted to an integer using `atoi` and used as an index to access the correct number of days from the array, which is printed as the output. The final code snippet is shown on the screen, and the instructor explains the logic of the program.
The video provides a clear, step-by-step tutorial on solving a common programming problem. It starts with a well-defined problem statement and test cases, then logically breaks down the solution into parsing the input, using a data structure (an array) to store the number of days per month, and finally writing the code to implement this logic. The progression from problem definition to code implementation is methodical and educational, making it a useful resource for learning basic string manipulation and array usage in C.

