Find number of days in the month from a given date

Duration: 6 min

This video lesson is available to enrolled students.

Return to /learn/LTI-MINDTREE-PREPARATION/coding/coding-questions/coding-question/asset-find-number-of-days-in-the-month-from-a-given-date after enrolling

Inside: a video lesson and guided study material.

Module outline

  1. English Comprehension/Verbal Ability: Comprehension / Reading Comprehension / Unseen Passages (Critical Reasoning) (Paragraph Questions) Vocabulary Sentence Correction (Error Correction) Sentence Completion (Fill in the blanks) Sentence Re-arrangements (Para Jumbles) (Narrative Sequencing) Subject Verb Agreement (Verb Noun Agreement) Tenses Verb Articles Preposition Conjunction Pronoun Noun Adjectives Adverb Modals Cloze Test (Cloze Passage) Active Passive Voice (Voice) Direct and Indirect Speech Sentence Construction
  2. Logical Ability: Coding Decoding Directions (Direction Test) Analogy Inequality Data Sufficiency Series (Number and Letter Series) (Numerical Relations and Reasoning) Syllogisms Seating Arrangements Puzzle Solving (Puzzles) Blood Relations Deductive and Inductive Reasoning (Logical Deduction and Induction) (Prepositional Reasoning) Ranking, Order and Sequence Logical Sequence Of Words Data Arrangement Venn Diagram Calendar Clock
  3. Quantitative Ability: Logarithm Permutation and Combination Probability Profit and Loss Speed Time and Distance Mixture and Alligation Partnership Simple Interest and Compound Interest Percentage Ratio and Proportion (Ratios) Average Time and Work Pipe and Cistern Number System Divisibility Rules HCF LCM Algebra Powers and Exponents (Surds and Indices) Mensuration and Geometry Age Problems Data Interpretation Sequence and Series (Series)
  4. Basic Analytical Ability: Non Verbal Reasoning (Spatial Aptitude) (Spatial Reasoning) (Visual Reasoning) Analytical Reasoning (Counting Figures Reasoning) Cubes & Dices Selection Decision Table (Decision Making)
  5. Computer Programming: Pseudo Codes Coding Questions by Yash Sir C Programming by Yash Sir Programming in C++ Java Python for Placements by Yash Sir
  6. DBMS (Computer Science): Basics of DBMS ER Diagram Relational Model & Functional Dependencies Keys & Integrity Constraints Normalization (1NF - BCNF) Transaction Management Concurrency Control Database Security & Authorization
  7. SQL (Computer Science): SQL
  8. OS (Computer Science): Introduction to OS Process Management CPU Scheduling Deadlock Process Synchronization Threads & Process Creation Memory Management Virtual Memory File Management
  9. Computer Networks (Computer Science): Introduction to CN Data Communication DLL: Access Control DLL: Flow Control DLL: Error Control DLL: Framing Data Link Layer - Ethernet Net Layer: IPv4 & Proto Net Layer: IP Addressing Net Layer:Routing Protocol Transport Layer Services TL: Congestion & UDP Application Layer Hardware basics Network Security
  10. Data Structures (Computer Science): Introduction to DS Array Stack Queue Linked List Tree Graphs Hashing
  11. OOPs (Computer Science): Object Oriented Programming (OOPS)
  12. Software Engineering (Computer Science): Fundamentals of Software Engineering Software Requirements and Quality Assurance Software Design, Estimation and Metrics Software Testing Software Maintenance and Configuration Management
  13. SVAR Conversational - Spoken English: Communication Assessment
  14. HR Interview: MR & HR Interview Preparation
  15. Coding Practice Questions: Coding Questions Bank
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

  1. 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. 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.

  3. 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.

Loading lesson…