Find number of days in the month from a given date
Duration: 6 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 that teaches how to write a C program to calculate the number of days in a given month from a user-provided date. The instructor begins by presenting the problem statement, which involves parsing a date in the format dd-mm-yyyy and finding the number of days in that month, with the simplification of ignoring leap years. The core of the lesson is a step-by-step walkthrough of a C code solution. The code uses an array to store the number of days for each month (January to December), with the value for February set to 28. The program prompts the user to enter a date, reads the input, and then uses the `strtok` function to split the date string by the hyphen delimiter. The month part is extracted, converted from a string to an integer using `atoi`, and used as an index to access the corresponding number of days from the array. The solution is then demonstrated in an online C compiler, where the user inputs a date, and the program correctly outputs the number of days in that month. The video is part of a series from 'Knowledge Gate' and is presented by an instructor named Yash Jain, who is visible in a small window throughout the lecture.
Chapters
0:00 – 2:00 00:00-02:00
The video starts with the 'Knowledge Gate' logo, followed by a slide that introduces the channel's various social media handles and educational offerings like 'KG GATE & PLACEMENT PREP' and 'KG CODING'. The main content begins with a presentation slide that clearly states the problem: 'Q10: User enters date in dd-mm-yyyy find out number of days in month (for now please ignore the concept of leap year)'. The slide provides the input and output format and includes public test cases, such as 'Input: 12-03-2006' with 'Output: 31'. The instructor, Yash Jain, is visible in a small window, and the video is presented as a lecture from 'Knowledge Gate Edventures'.
2:00 – 5:00 02:00-05:00
The instructor displays a C code solution on a digital blackboard. The code begins with standard includes: `#include <stdio.h>`, `#include <string.h>`. The main function is defined, and an integer array `arr` is initialized with the number of days for each month, starting with 31 for January and ending with 31 for December, with February set to 28. The code prompts the user to 'Enter date'. It declares a character array `date[11]` to store the input and a pointer `token` for string parsing. The `scanf` function reads the date string. The instructor then explains the use of `strtok` to split the date string by the hyphen delimiter. The month part is extracted, converted to an integer using `atoi`, and used to index the `arr` array to get the number of days. The final output is printed using `printf("Month has %d days", arr[i-1]);`. The instructor uses a whiteboard to draw arrows and write notes like 'dd-mm-yyyy' and 'token' to explain the logic.
5:00 – 5:42 05:00-05:42
The video transitions to a screen recording of the 'GDB Online' compiler. The instructor pastes the C code into the editor. The code is successfully compiled, as indicated by the 'Compiled Successfully' message. The instructor then runs the program, and the 'Input' field appears. He types '12-03-2006' and presses enter. The program executes and correctly outputs 'Month has 31 days', demonstrating that the solution works for the given test case. The instructor confirms the result, concluding the practical demonstration of the code.
The video provides a comprehensive, step-by-step tutorial on solving a common programming problem. It begins with a clear problem definition, followed by a detailed explanation of the algorithm, which relies on a pre-defined array of month days and string parsing functions. The instructor methodically walks through the code, explaining each line and the logic behind it. The lesson is effectively concluded with a live demonstration in an online compiler, which validates the solution's correctness. This approach, combining theory, code walkthrough, and practical execution, makes the content highly educational for students learning C programming.

